diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-01-04 12:02:22 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-01-08 12:41:24 -0800 |
commit | 8e577fe560d5756fcc67840ba304d79ada6804e4 (patch) | |
tree | 4826e41e676ac89d5c17b0b4eb20c939a166c3fb /actionpack/test/dispatch/request/xml_params_parsing_test.rb | |
parent | c31cc963daac55f6a3bca9da99b619276911dbd7 (diff) | |
download | rails-8e577fe560d5756fcc67840ba304d79ada6804e4.tar.gz rails-8e577fe560d5756fcc67840ba304d79ada6804e4.tar.bz2 rails-8e577fe560d5756fcc67840ba304d79ada6804e4.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/test/dispatch/request/xml_params_parsing_test.rb')
-rw-r--r-- | actionpack/test/dispatch/request/xml_params_parsing_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/request/xml_params_parsing_test.rb b/actionpack/test/dispatch/request/xml_params_parsing_test.rb index cb68667002..f13b64a3c7 100644 --- a/actionpack/test/dispatch/request/xml_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/xml_params_parsing_test.rb @@ -30,6 +30,23 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest assert_equal "<ok>bar</ok>", resp.body end + def assert_parses(expected, xml) + with_test_routing do + post "/parse", xml, default_headers + assert_response :ok + assert_equal(expected, TestController.last_request_parameters) + end + end + + test "nils are stripped from collections" do + assert_parses( + {"hash" => { "person" => nil} }, + "<hash><person type=\"array\"><person nil=\"true\"/></person></hash>") + assert_parses( + {"hash" => { "person" => ['foo']} }, + "<hash><person type=\"array\"><person>foo</person><person nil=\"true\"/></person>\n</hash>") + end + test "parses hash params" do with_test_routing do xml = "<person><name>David</name></person>" |