arachni-typhoeus 0.2.0.1 → 0.2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.1
1
+ 0.2.0.2
@@ -110,18 +110,23 @@ module Typhoeus
110
110
  end
111
111
 
112
112
  def params_string
113
- params.keys.sort { |a, b| a.to_s <=> b.to_s }.collect do |k|
114
- value = params[k]
115
- if value.is_a? Hash
116
- value.keys.collect {|sk| Typhoeus::Utils.escape("#{k}[#{sk}]") + "=" + Typhoeus::Utils.escape(value[sk].to_s)}
117
- elsif value.is_a? Array
118
- key = Typhoeus::Utils.escape(k.to_s)
119
- value.collect { |v| "#{key}[]=#{Typhoeus::Utils.escape(v.to_s)}" }.join('&')
113
+ traverse_hash(params).flatten.join('&')
114
+ end
115
+
116
+ def traverse_hash(hash, current_key = nil)
117
+ hash.keys.sort { |a, b| a.to_s <=> b.to_s }.collect do |key|
118
+ new_key = current_key ? "#{current_key}[#{key}]" : key
119
+ if hash[key].is_a?(Hash)
120
+ traverse_hash(hash[key], new_key)
121
+ elsif hash[key].is_a?(Array)
122
+ array_key = Typhoeus::Utils.escape("#{new_key}[]")
123
+ hash[key].collect { |v| "#{array_key}=#{Typhoeus::Utils.escape(v.to_s)}" }.join('&')
120
124
  else
121
- "#{Typhoeus::Utils.escape(k.to_s)}=#{Typhoeus::Utils.escape(params[k].to_s)}"
125
+ "#{Typhoeus::Utils.escape(new_key)}=#{Typhoeus::Utils.escape(hash[key].to_s)}"
122
126
  end
123
- end.flatten.join("&")
127
+ end
124
128
  end
129
+ private :traverse_hash
125
130
 
126
131
  def on_complete(&block)
127
132
  @on_complete = block
@@ -2,7 +2,7 @@ module Typhoeus
2
2
  module Utils
3
3
  # Taken from Rack::Utils, 1.2.1 to remove Rack dependency.
4
4
  def escape(s)
5
- s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/u) {
5
+ s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/) {
6
6
  '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
7
7
  }.tr(' ', '+')
8
8
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 2
8
8
  - 0
9
- - 1
10
- version: 0.2.0.1
9
+ - 2
10
+ version: 0.2.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Dix
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-02-02 00:00:00 +00:00
19
+ date: 2011-02-19 00:00:00 +00:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency