aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-05-20 10:04:12 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2012-05-20 19:07:04 +0100
commit66eb3f02cc0894f08c4f912ba8bf6fb1f87e9a4a (patch)
treece416e619f911d542845eb1fe787f7d5f02cf593 /actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
parent972376a9952ce3a1cb1babb9e408900d314ac577 (diff)
downloadrails-66eb3f02cc0894f08c4f912ba8bf6fb1f87e9a4a.tar.gz
rails-66eb3f02cc0894f08c4f912ba8bf6fb1f87e9a4a.tar.bz2
rails-66eb3f02cc0894f08c4f912ba8bf6fb1f87e9a4a.zip
Raise ActionController::BadRequest for malformed parameter hashes.
Currently Rack raises a TypeError when it encounters a malformed or ambiguous hash like `foo[]=bar&foo[4]=bar`. Rather than pass this through to the application this commit captures the exception and re-raises it using a new ActionController::BadRequest exception. The new ActionController::BadRequest exception returns a 400 error instead of the 500 error that would've been returned by the original TypeError. This allows exception notification libraries to ignore these errors if so desired. Closes #3051
Diffstat (limited to 'actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb')
-rw-r--r--actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
index 568e220b15..e9b59f55a7 100644
--- a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
@@ -126,6 +126,17 @@ class UrlEncodedParamsParsingTest < ActionDispatch::IntegrationTest
assert_parses expected, query
end
+ test "ambiguous params returns a bad request" do
+ with_routing do |set|
+ set.draw do
+ post ':action', :to => ::UrlEncodedParamsParsingTest::TestController
+ end
+
+ post "/parse", "foo[]=bar&foo[4]=bar"
+ assert_response :bad_request
+ end
+ end
+
private
def with_test_routing
with_routing do |set|