From 48b57c621a9271bd050bfce930fb0828072a6b0d Mon Sep 17 00:00:00 2001 From: Mark Reginald James Date: Wed, 24 Dec 2008 04:49:20 +1100 Subject: [PATCH] Fixed incorrect parsing of query parameters with mixed-depth nesting inside an array --- actionpack/lib/action_controller/request.rb | 4 ++-- actionpack/test/controller/request_test.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 2cad7bc..395aa7c 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -832,9 +832,9 @@ EOM top[-1][key] = value else top << {key => value}.with_indifferent_access - push top.last - value = top[key] end + push top.last + value = top[key] # Get the indifferent_access form of value else top << value end diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index c2c35ad..5550633 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -443,6 +443,7 @@ class UrlEncodedRequestParameterParsingTest < ActiveSupport::TestCase def test_deep_query_string_with_array_of_hash assert_equal({'x' => {'y' => [{'z' => '10'}]}}, ActionController::Request.parse_query_parameters('x[y][][z]=10')) assert_equal({'x' => {'y' => [{'z' => '10', 'w' => '10'}]}}, ActionController::Request.parse_query_parameters('x[y][][z]=10&x[y][][w]=10')) + assert_equal({'x' => {'y' => [{'z' => '10', 'v' => {'w' => '10'}}]}}, ActionController::Request.parse_query_parameters('x[y][][z]=10&x[y][][v][w]=10')) end def test_deep_query_string_with_array_of_hashes_with_one_pair -- 1.6.0