aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb4
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb33
2 files changed, 25 insertions, 12 deletions
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb
index 63f2098003..d77fa26575 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb
@@ -108,7 +108,7 @@ module Rack
else
@env["rack.request.query_string"] = query_string
@env["rack.request.query_hash"] =
- Utils.parse_query(query_string)
+ Utils.parse_nested_query(query_string)
end
end
@@ -129,7 +129,7 @@ module Rack
form_vars.sub!(/\0\z/, '')
@env["rack.request.form_vars"] = form_vars
- @env["rack.request.form_hash"] = Utils.parse_query(form_vars)
+ @env["rack.request.form_hash"] = Utils.parse_nested_query(form_vars)
begin
@env["rack.input"].rewind if @env["rack.input"].respond_to?(:rewind)
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb
index d13a5dfad0..f352cb6783 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb
@@ -29,19 +29,39 @@ module Rack
# and ';' characters. You can also use this to parse
# cookies by changing the characters used in the second
# parameter (which defaults to '&;').
-
def parse_query(qs, d = '&;')
params = {}
(qs || '').split(/[#{d}] */n).each do |p|
k, v = unescape(p).split('=', 2)
- normalize_params(params, k, v)
+
+ if cur = params[k]
+ if cur.class == Array
+ params[k] << v
+ else
+ params[k] = [cur, v]
+ end
+ else
+ params[k] = v
+ end
end
return params
end
module_function :parse_query
+ def parse_nested_query(qs, d = '&;')
+ params = {}
+
+ (qs || '').split(/[#{d}] */n).each do |p|
+ k, v = unescape(p).split('=', 2)
+ normalize_params(params, k, v)
+ end
+
+ return params
+ end
+ module_function :parse_nested_query
+
def normalize_params(params, name, v = nil)
name =~ %r([\[\]]*([^\[\]]+)\]*)
k = $1 || ''
@@ -50,14 +70,7 @@ module Rack
return if k.empty?
if after == ""
- cur = params[k]
- if cur.is_a?(Array)
- params[k] << v
- elsif cur && name == $1
- params[k] = [cur, v]
- else
- params[k] = v
- end
+ params[k] = v
elsif after == "[]"
params[k] ||= []
raise TypeError unless params[k].is_a?(Array)