aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/request.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-01-04 12:02:22 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2013-01-07 17:20:12 -0800
commitd99e8c9e1618f509bb35f052d4bd0d1848bce771 (patch)
tree4692f089b25801a251758cd8332a33391a4a6ac8 /actionpack/lib/action_dispatch/http/request.rb
parentefbb041fb0146d5f633c2e645217f3a734539f11 (diff)
downloadrails-d99e8c9e1618f509bb35f052d4bd0d1848bce771.tar.gz
rails-d99e8c9e1618f509bb35f052d4bd0d1848bce771.tar.bz2
rails-d99e8c9e1618f509bb35f052d4bd0d1848bce771.zip
* Strip nils from collections on JSON and XML posts. [CVE-2013-0155] * dealing with empty hashes. Thanks Damien Mathieu
Conflicts: actionpack/CHANGELOG.md actionpack/lib/action_dispatch/http/request.rb actionpack/lib/action_dispatch/middleware/params_parser.rb activerecord/CHANGELOG.md activerecord/lib/active_record/relation/predicate_builder.rb activerecord/test/cases/relation/where_test.rb
Diffstat (limited to 'actionpack/lib/action_dispatch/http/request.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index 452809a689..31b36eedb0 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -276,15 +276,14 @@ module ActionDispatch
LOCALHOST =~ remote_addr && LOCALHOST =~ remote_ip
end
- protected
-
# Remove nils from the params hash
def deep_munge(hash)
- hash.each_value do |v|
+ hash.each do |k, v|
case v
when Array
v.grep(Hash) { |x| deep_munge(x) }
v.compact!
+ hash[k] = nil if v.empty?
when Hash
deep_munge(v)
end
@@ -293,6 +292,8 @@ module ActionDispatch
hash
end
+ protected
+
def parse_query(qs)
deep_munge(super)
end