diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-02-14 18:23:08 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-02-14 18:23:08 -0600 |
commit | 238a6bb62dc153743a0abc6eb1e35392ac799d65 (patch) | |
tree | 7946cf401039a51edd07ade5f7e9d1111af3733a /actionpack/lib/action_controller/vendor | |
parent | 0cb020b4d6d838025859bd60fb8151c8e21b8e84 (diff) | |
download | rails-238a6bb62dc153743a0abc6eb1e35392ac799d65.tar.gz rails-238a6bb62dc153743a0abc6eb1e35392ac799d65.tar.bz2 rails-238a6bb62dc153743a0abc6eb1e35392ac799d65.zip |
Update bundled rack to fix more parameter parsing issues
Diffstat (limited to 'actionpack/lib/action_controller/vendor')
-rw-r--r-- | actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb | 33 |
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) |