diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-12 09:10:58 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-12 09:10:58 +0000 |
commit | 41198ad3ad1925b2b88df9b16638c36dee43500f (patch) | |
tree | a9afcc4da1cc81e24add5a713556cb89a3f6f58a /actionpack/lib/action_controller | |
parent | c62e5e1a3a60c2360ae5a356bf7697dd4417ecb6 (diff) | |
download | rails-41198ad3ad1925b2b88df9b16638c36dee43500f.tar.gz rails-41198ad3ad1925b2b88df9b16638c36dee43500f.tar.bz2 rails-41198ad3ad1925b2b88df9b16638c36dee43500f.zip |
Fix parsing of array[] CGI parameters so extra empty values aren't included. Closes #6252.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5904 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-x | actionpack/lib/action_controller/cgi_ext/cgi_methods.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb index 329a11969a..437a340b25 100755 --- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb +++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb @@ -23,18 +23,19 @@ class CGIMethods #:nodoc: def parse_request_parameters(params) parser = FormEncodedPairParser.new - finished = false - until finished - finished = true + params = params.dup + until params.empty? for key, value in params - next if key.blank? - if !key.include?('[') + if key.blank? + params.delete key + elsif !key.include?('[') # much faster to test for the most common case first (GET) # and avoid the call to build_deep_hash parser.result[key] = get_typed_value(value[0]) + params.delete key elsif value.is_a?(Array) parser.parse(key, get_typed_value(value.shift)) - finished = false unless value.empty? + params.delete key if value.empty? else raise TypeError, "Expected array, found #{value.inspect}" end |