diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-01 12:57:16 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-01 12:57:16 +0000 |
commit | 50f333b203756009acff2457b6d1c9da3b532cad (patch) | |
tree | 14394927c17e2bdf212fbe77c8fb7deed7c6d4bd /actionpack/test/controller | |
parent | 79e85edd71a4c886b1ac074988963588d8c45755 (diff) | |
download | rails-50f333b203756009acff2457b6d1c9da3b532cad.tar.gz rails-50f333b203756009acff2457b6d1c9da3b532cad.tar.bz2 rails-50f333b203756009acff2457b6d1c9da3b532cad.zip |
Added graceful handling of non-alphanumeric names and misplaced brackets in input parameters [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@39 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rwxr-xr-x | actionpack/test/controller/cgi_test.rb | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb index 46e24ab403..2cee763491 100755 --- a/actionpack/test/controller/cgi_test.rb +++ b/actionpack/test/controller/cgi_test.rb @@ -133,10 +133,40 @@ class CGITest < Test::Unit::TestCase end def test_parse_params_with_array - input = { "selected[]" => [ "1", "2", "3" ] } + input = { "selected[]" => [ "1", "2", "3" ] } - expected_output = { "selected" => [ "1", "2", "3" ] } + expected_output = { "selected" => [ "1", "2", "3" ] } - assert_equal expected_output, CGIMethods.parse_request_parameters(input) + assert_equal expected_output, CGIMethods.parse_request_parameters(input) + end + + def test_parse_params_with_non_alphanumeric_name + input = { "a/b[c]" => %w(d) } + expected = { "a/b" => { "c" => "d" }} + assert_equal expected, CGIMethods.parse_request_parameters(input) + end + + def test_parse_params_with_single_brackets_in_middle + input = { "a/b[c]d" => %w(e) } + expected = { "a/b[c]d" => "e" } + assert_equal expected, CGIMethods.parse_request_parameters(input) + end + + def test_parse_params_with_separated_brackets + input = { "a/b@[c]d[e]" => %w(f) } + expected = { "a/b@" => { "c]d[e" => "f" }} + assert_equal expected, CGIMethods.parse_request_parameters(input) + end + + def test_parse_params_with_separated_brackets_and_array + input = { "a/b@[c]d[e][]" => %w(f) } + expected = { "a/b@" => { "c]d[e" => ["f"] }} + assert_equal expected , CGIMethods.parse_request_parameters(input) + end + + def test_parse_params_with_unmatched_brackets_and_array + input = { "a/b@[c][d[e][]" => %w(f) } + expected = { "a/b@" => { "c" => { "d[e" => ["f"] }}} + assert_equal expected, CGIMethods.parse_request_parameters(input) end end |