File 2-3-null_array_param.patch of Package rubygem-actionpack-2_3
Index: lib/action_controller/request.rb
===================================================================
--- lib/action_controller/request.rb.orig 2012-07-18 16:28:20.433076369 +0200
+++ lib/action_controller/request.rb 2012-07-18 16:29:56.813242333 +0200
@@ -495,17 +495,19 @@ EOM
# 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
Index: test/controller/request/query_string_parsing_test.rb
===================================================================
--- test/controller/request/query_string_parsing_test.rb.orig 2012-07-18 16:28:20.436077868 +0200
+++ test/controller/request/query_string_parsing_test.rb 2012-07-18 16:32:20.072439141 +0200
@@ -89,6 +89,10 @@ class QueryStringParsingTest < ActionCon
assert_parses({"action"=>{"foo"=>[{"bar"=>nil}]}}, "action[foo][][bar]")
end
+ def test_array_parses_without_nil
+ assert_parses({"action" => ['1']}, "action[]=1&action[]")
+ end
+
test "query string with empty key" do
assert_parses(
{ "action" => "create_customer", "full_name" => "David Heinemeier Hansson" },