spiderfw 0.6.37 → 0.6.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd306987f2889111e541450c6b4b3140a380111e
4
- data.tar.gz: 6941bf11587b4802e48bf4ac0c8195f305a64c72
3
+ metadata.gz: bbf6ae93620ab61203cc996d8fbcbbc097a4b737
4
+ data.tar.gz: 0f4de9878544dc7b5b4bc5876ffaa250a4290465
5
5
  SHA512:
6
- metadata.gz: 225d9c4ff0e49be66e331a48fe7f15b04ed418ed1612755b2c8c429eb407ef3343f829a110713c6d25f11aeefc3cb85db5615111572c63713267fed4ca511541
7
- data.tar.gz: 4b1bb18864a2a3c73f4a0d5965493c8b82a167f2fefae382b3f265cb244c626c1970c60ac2c60c6e4fe723214c77206b22b5aa09dc8d92aa5f61cbc1cea2d996
6
+ metadata.gz: 614afbce4f39464a467282fdd6a51b7e8ffba870c5261eec57b4248735c3a45558060dcb10c4140c22011860819c49096cd962ed4db5601bd62446c8d1ec9e21
7
+ data.tar.gz: db21914ca3d1859a8e02023d086b15ed580920a98ba4053dfa56afc84eeef0087a3ef07cb328cf6bbdc21126e4ebbaa38f5d10e65a81ac55af2f1dd14692b53d
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.6.38
2
+ * Aggiunto path per fare il logout cas
3
+ * Modificato cas.rb e log vari
4
+ * aggiunto controllo per ruby 1.8
5
+ * Cancellazione di un file caricato con widget file input
6
+ * aggiunta options host per webserver, a seguito di modifiche intervenute su gem rack ver 1.6.0
7
+ * aggiunta gestione encoding per ruby > 1.8.7 nella funzione to_json
8
+ * aggiunta gestione corretta per usare pry e pry-byebug
9
+ * Ricavo encoding da request per creare un tempfile con upload file da form
10
+ == 0.6.37
1
11
  == 0.6.36
2
12
  * correzioni bugs
3
13
  * gestione di caricamento del path dell'app rivisto e corretto anche per windows
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.37
1
+ 0.6.38
@@ -10,5 +10,6 @@ module Spider
10
10
  config_option 'cas.saml_compliant_tickets', :type => String, :choices => [false, '1', '2', '4'], :default => lambda{
11
11
  Spider.conf.get('cas.saml1_1_compatible') ? '1' : false
12
12
  }
13
+ config_option 'cas.url_logout_cas', "Indirizzo url assoluto per il logout generale tramite CAS dei servizi php", :type => String
13
14
 
14
15
  end
@@ -222,7 +222,7 @@ module Spider; module CASServer
222
222
  TicketGrantingTicket.storage.commit
223
223
  rescue Exception => exc
224
224
  TicketGrantingTicket.storage.rollback
225
- Spider.logger.error "** Errore logout cas"
225
+ $LOG.error "** Errore logout cas"
226
226
 
227
227
  end
228
228
 
@@ -1,5 +1,6 @@
1
1
  require 'uri'
2
2
  require 'net/https'
3
+ require "net/http"
3
4
  require 'apps/cas_server/lib/utils'
4
5
 
5
6
  # Encapsulates CAS functionality. This module is meant to be included in
@@ -273,13 +274,19 @@ module Spider; module CASServer::CAS
273
274
  path = uri.path
274
275
  path = '/' if path.empty?
275
276
 
277
+ url_logout_cas = Spider.conf.get('cas.url_logout_cas')
278
+ path = url_logout_cas unless url_logout_cas.blank?
279
+
276
280
  req = Net::HTTP::Post.new(path)
281
+ str_saml_logout = %{<samlp:LogoutRequest ID="#{rand}" Version="2.0" IssueInstant="#{time.rfc2822}">
282
+ <saml:NameID></saml:NameID>
283
+ <samlp:SessionIndex>#{st.ticket}</samlp:SessionIndex>
284
+ </samlp:LogoutRequest>}
285
+
286
+ Spider.logger.debug "*** Logout saml#{str_saml_logout}"
277
287
  req.set_form_data(
278
- 'logoutRequest' => %{<samlp:LogoutRequest ID="#{rand}" Version="2.0" IssueInstant="#{time.rfc2822}">
279
- <saml:NameID></saml:NameID>
280
- <samlp:SessionIndex>#{st.ticket}</samlp:SessionIndex>
281
- </samlp:LogoutRequest>}
282
- )
288
+ 'logoutRequest' => str_saml_logout
289
+ )
283
290
 
284
291
  http.start do |conn|
285
292
  response = conn.request(req)
@@ -27,12 +27,14 @@ module Spider; module Forms
27
27
  if val['file'] && !val['file'].is_a?(String)
28
28
  dest_path = @save_path+'/'+val['file'].filename
29
29
  FileUtils.copy(val['file'].path, dest_path)
30
- return dest_path
31
- elsif val['clear']
30
+ end
31
+ #se clicco su pulisci cancello il file
32
+ if val['clear'] == 'on'
33
+ FileUtils.rm_f(val['file_name']) if File.exist?(val['file_name'])
32
34
  self.value = nil
33
- return
35
+ return 'cancellato' if val['file'].blank?
34
36
  end
35
- return @value
37
+ return (dest_path.blank? ? self.value : dest_path)
36
38
  end
37
39
 
38
40
  __.action
@@ -5,6 +5,7 @@
5
5
  <div sp:if="@value && !@value.to_s.empty?">
6
6
  <a class="file-link" href="{ widget_action('view_file') }">{ @formatted_value }</a>
7
7
  <span class="clear">(<input type="checkbox" name="{ @name }[clear]"> _(Clear))</span>
8
+ <input type="hidden" name="{ @name }[file_name]" id="input_name_file" value="{ @value }">
8
9
  </div>
9
10
  <div class="change"><span sp:if="@value && !@value.to_s.empty?"><span class="change-label">_(Change)</span>:</span>
10
11
  <input type="file" name="{ @name }[file]" id="input" value="{ @value }" size="{ @size }">
@@ -28,6 +28,7 @@ module Spider
28
28
  config_option 'webserver.reload_sources', _("Reload application and spider sources on each request"),
29
29
  :type => Spider::DataTypes::Bool,
30
30
  :default => Proc.new{ Spider.config.get('runmode') == 'devel' ? true : false }
31
+ config_option 'webserver.host', _("Port to use for the http server"), :type => Fixnum, :default => '0.0.0.0'
31
32
  config_option 'webserver.port', _("Port to use for the http server"), :type => Fixnum, :default => 8080
32
33
  config_option 'webserver.force_threads', _("Force threading on non-threaded adapters"), :type => Spider::DataTypes::Bool,
33
34
  :default => Proc.new{ Spider.runmode != 'test' && RUBY_VERSION_PARTS[1] == '8'}
@@ -12,7 +12,7 @@ module Spider; module HTTP
12
12
  def options(opts)
13
13
  opts = super(opts)
14
14
  defaults = {
15
- :host => 'localhost',
15
+ :Host => '0.0.0.0',
16
16
  :app => 'spider'
17
17
  }
18
18
  return defaults.merge(opts)
@@ -22,10 +22,13 @@ module Spider; module HTTP
22
22
  def start_server(opts={})
23
23
  opts = options(opts)
24
24
  options = {
25
- :Port => opts[:port],
26
- :BindAddress => opts[:host]
25
+ :Port => opts[:Port],
26
+ :BindAddress => opts[:Host]
27
27
  }
28
- @server = ::Thin::Server.start(opts[:host], opts[:port].to_i, Spider::HTTP::RackApplication.new)
28
+ @server = ::Thin::Server.start(opts[:Host], opts[:Port].to_i, Spider::HTTP::RackApplication.new) do
29
+ use Rack::CommonLogger
30
+ use Rack::ShowExceptions
31
+ end
29
32
  end
30
33
 
31
34
  def shutdown_server
@@ -272,9 +272,9 @@ module Spider
272
272
  filename = head[FILENAME_REGEX, 1]
273
273
  content_type = head[CONTENT_TYPE_REGEX, 1]
274
274
  name = head[NAME_REGEX, 1]
275
-
276
275
  if filename && !filename.empty?
277
- body = UploadedFile.new(filename, content_type)
276
+ #se sono con ruby >= 1.9 ricavo l'encoding
277
+ body = UploadedFile.new(filename, content_type, (buf.respond_to?(:encoding) ? buf.encoding.to_s : nil) )
278
278
  end
279
279
  next
280
280
  end
@@ -317,13 +317,18 @@ module Spider
317
317
 
318
318
 
319
319
  class UploadedFile < ::Tempfile
320
- attr_reader :filename, :content_type
320
+ #aggiunto encoding per problemi con upload file "\xFF" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
321
+ attr_reader :filename, :content_type, :encoding
321
322
 
322
- def initialize(filename, content_type)
323
+ def initialize(filename, content_type, encoding)
323
324
  @filename = filename
324
325
  @content_type = content_type
325
- super('uploaded', Spider.paths[:tmp])
326
-
326
+ @encoding = encoding
327
+ if RUBY_VERSION >= "1.9"
328
+ super('uploaded', Spider.paths[:tmp], content_type, :encoding => encoding)
329
+ else #caso con ruby 1.8.7
330
+ super('uploaded', Spider.paths[:tmp])
331
+ end
327
332
  end
328
333
 
329
334
  end
@@ -20,7 +20,7 @@ module Spider; module HTTP
20
20
  :host => '0.0.0.0',
21
21
  :port => 8080
22
22
  }
23
- return defaults.merge(opts)
23
+ return defaults.merge!(opts)
24
24
  end
25
25
 
26
26
  def start(opts={})
@@ -39,9 +39,11 @@ module Spider; module HTTP
39
39
 
40
40
  def self.get_opts(server_name, options)
41
41
  server_name ||= Spider.conf.get('http.server')
42
+ options[:host] ||= Spider.conf.get('webserver.host')
42
43
  options[:port] ||= Spider.conf.get('webserver.port')
43
44
  opts = {
44
45
  :server => server_name,
46
+ :Host => options[:host],
45
47
  :Port => options[:port],
46
48
  :config => File.join(Spider.paths[:root], 'config.ru')
47
49
  }
@@ -84,12 +86,12 @@ module Spider; module HTTP
84
86
  end
85
87
 
86
88
  def self.start(server_name, options={})
87
- start = lambda{
89
+ start = Proc.new{
88
90
 
89
91
 
90
92
  pid_file = File.join(Spider.paths[:var], 'run/server.pid')
91
93
  puts _("Using webserver %s") % server_name if options[:verbose]
92
- puts _("Listening on port %s") % opts[:port] if options[:verbose]
94
+ puts _("Listening on port %s") % opts[:Port] if options[:verbose]
93
95
  rack = nil
94
96
  ssl_rack = nil
95
97
  server = nil
@@ -132,11 +134,11 @@ module Spider; module HTTP
132
134
  end
133
135
  }
134
136
  Spider.on_shutdown(&do_shutdown)
135
-
136
137
  begin
137
138
  thread.join if thread
138
139
  ssl_thread.join if ssl_thread
139
140
  rescue SystemExit
141
+ Spider.logger.error "Problema nella creazione di un thread"
140
142
  end
141
143
  }
142
144
  if options[:daemonize]
@@ -1,3 +1,4 @@
1
+ # coding: UTF-8
1
2
  # -*- encoding : utf-8 -*-
2
3
  require 'spiderfw/model/mixins/state_machine'
3
4
  require 'spiderfw/model/element'
@@ -2452,16 +2453,25 @@ module Spider; module Model
2452
2453
  val = get(name)
2453
2454
  enc = Spider.conf.get('storages')['default']['encoding']
2454
2455
  enc ||= 'UTF-8'
2455
-
2456
2456
  if (el.type == String || el.type == Text)
2457
2457
  if RUBY_VERSION =~ /1.8/
2458
2458
  val = ic.iconv(val + ' ')[0..-2] if val
2459
- else
2459
+ elsif val.encoding == "ASCII-8BIT" && val.is_a?(String)
2460
+ begin
2461
+ val = ((val+' ').force_encoding("UTF-8").encode('UTF-8', :invalid => :replace, :undef => :replace))[0..-2] if val
2462
+ rescue
2463
+ Spider.logger.error("Errore di encoding relativamente al seguente valore inserito in json #{val}")
2464
+ ensure
2465
+ val ||= ''
2466
+ end
2467
+ elsif val.is_a?(String)
2460
2468
  begin
2461
- val = ((val+' ').encode('UTF-8', enc, :invalid => :replace, :undef => :replace))[0..-2] if val
2462
- rescue EncodingError
2463
- val = ''
2464
- end
2469
+ val = ((val+' ').encode('UTF-8', enc))[0..-2] if val
2470
+ rescue EncodingError
2471
+ val = ((val+' ').encode('UTF-8', 'UTF-8', :invalid => :replace, :undef => :replace))[0..-2] if val
2472
+ ensure
2473
+ val ||= ''
2474
+ end
2465
2475
  end
2466
2476
  end
2467
2477
  val = val.to_json
@@ -2628,7 +2638,7 @@ module Spider; module Model
2628
2638
  return pks[0] if pks.length == 1
2629
2639
  return pks
2630
2640
  end
2631
-
2641
+ ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') if RUBY_VERSION =~ /1.8/
2632
2642
  self.class.elements_array.each do |el|
2633
2643
  next unless mapper.have_references?(el) || (el.junction? && el.model.attributes[:sub_model] == self.class)
2634
2644
  if (el.model?)
@@ -2646,6 +2656,12 @@ module Spider; module Model
2646
2656
  case val.class.name.to_sym
2647
2657
  when :Date, :DateTime, :Time
2648
2658
  val = val.strftime
2659
+ when :String
2660
+ if RUBY_VERSION =~ /1.8/
2661
+ val = ic.iconv(val) if val
2662
+ else
2663
+ val = val = val.force_encoding(Encoding::UTF_8).encode(Encoding::UTF_8) if val && val.encoding == Encoding::ASCII_8BIT
2664
+ end
2649
2665
  end
2650
2666
  end
2651
2667
  h[el.name] = val
@@ -25,6 +25,9 @@ module Spider; module DataTypes
25
25
  return self.to_s if attributes[:hashed]
26
26
  salt = attributes[:salt] || Spider.conf.get('password.salt')
27
27
  # TODO: better salts
28
+ #(0..10) -> ruby range, cioe crea un array da 0 a 10
29
+ #rand(89) numero casuale tra 0 e 88
30
+ #si ottiene un salt di 11 caratteri casuali che serve per effettuare l'hash
28
31
  salt ||= (0..10).inject('') { |r, i| r << rand(89) + 37 }
29
32
  hash_type = attributes[:hash] || Spider.conf.get('password.hash')
30
33
  return "#{hash_type}$#{salt}$#{self.class.do_hash(hash_type, self.to_s, salt)}"
@@ -1119,7 +1119,7 @@ module Spider
1119
1119
  def init_pry_debug
1120
1120
  begin
1121
1121
  require 'pry'
1122
- require 'pry-nav'
1122
+ #require 'pry-nav'
1123
1123
  require 'pry-stack_explorer'
1124
1124
  if File.exists?(File.join($SPIDER_RUN_PATH,'tmp', 'debug.txt'))
1125
1125
  require 'pry-remote'
@@ -1132,8 +1132,10 @@ module Spider
1132
1132
  case RUBY_VERSION
1133
1133
  when /2/
1134
1134
  require 'byebug'
1135
+ require 'pry-byebug'
1135
1136
  else
1136
1137
  require 'ruby-debug'
1138
+ require 'pry-debugger'
1137
1139
  end
1138
1140
  rescue
1139
1141
  require 'debugger'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiderfw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.37
4
+ version: 0.6.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Pirlik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-02 00:00:00.000000000 Z
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse