aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/request.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-06-12 14:25:45 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-06-12 14:25:45 -0700
commit2be40a873ecbbdc344b9933b9a6db80f7fead7f2 (patch)
treeb2eebbdfaa429a1ae3d3bcce04873d463ec34f68 /actionpack/lib/action_dispatch/http/request.rb
parent6ff78a188a953fb06ebae469e17d3fa6917f08e2 (diff)
parent24894fc13037e849bceb3e1999bf41326f5d8077 (diff)
downloadrails-2be40a873ecbbdc344b9933b9a6db80f7fead7f2.tar.gz
rails-2be40a873ecbbdc344b9933b9a6db80f7fead7f2.tar.bz2
rails-2be40a873ecbbdc344b9933b9a6db80f7fead7f2.zip
Merge branch 'master-sec'
* master-sec: Array parameters should not contain nil values.
Diffstat (limited to 'actionpack/lib/action_dispatch/http/request.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index 6757a53bd1..65ff6fb7d8 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -267,17 +267,19 @@ module ActionDispatch
# Remove nils from the params hash
def deep_munge(hash)
+ keys = hash.keys.find_all { |k| hash[k] == [nil] }
+ keys.each { |k| hash[k] = nil }
+
hash.each_value do |v|
case v
when Array
v.grep(Hash) { |x| deep_munge(x) }
+ v.compact!
when Hash
deep_munge(v)
end
end
- keys = hash.keys.find_all { |k| hash[k] == [nil] }
- keys.each { |k| hash[k] = nil }
hash
end