1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #25799 from greysteil/wrap-rack-params-exceptions

Handle `Rack::QueryParser` errors in `ActionDispatch::ExceptionWrapper`
This commit is contained in:
Matthew Draper 2016-07-14 00:58:30 +09:30 committed by GitHub
commit 3b55ac22c9
3 changed files with 14 additions and 2 deletions

View file

@ -1,2 +1,8 @@
* Handle `Rack::QueryParser` errors in `ActionDispatch::ExceptionWrapper`
Updated `ActionDispatch::ExceptionWrapper` to handle the Rack 2.0 namespace
for `ParameterTypeError` and `InvalidParameterError` errors.
*Grey Baker*
Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/actionpack/CHANGELOG.md) for previous changes. Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/actionpack/CHANGELOG.md) for previous changes.

View file

@ -17,8 +17,8 @@ module ActionDispatch
'ActionDispatch::ParamsParser::ParseError' => :bad_request, 'ActionDispatch::ParamsParser::ParseError' => :bad_request,
'ActionController::BadRequest' => :bad_request, 'ActionController::BadRequest' => :bad_request,
'ActionController::ParameterMissing' => :bad_request, 'ActionController::ParameterMissing' => :bad_request,
'Rack::Utils::ParameterTypeError' => :bad_request, 'Rack::QueryParser::ParameterTypeError' => :bad_request,
'Rack::Utils::InvalidParameterError' => :bad_request 'Rack::QueryParser::InvalidParameterError' => :bad_request
) )
cattr_accessor :rescue_templates cattr_accessor :rescue_templates

View file

@ -57,6 +57,12 @@ module ActionDispatch
assert_equal [ "lib/file.rb:42:in `index'" ], wrapper.application_trace assert_equal [ "lib/file.rb:42:in `index'" ], wrapper.application_trace
end end
test '#status_code returns 400 for Rack::Utils::ParameterTypeError' do
exception = Rack::Utils::ParameterTypeError.new
wrapper = ExceptionWrapper.new(@cleaner, exception)
assert_equal 400, wrapper.status_code
end
test '#application_trace cannot be nil' do test '#application_trace cannot be nil' do
nil_backtrace_wrapper = ExceptionWrapper.new(@cleaner, BadlyDefinedError.new) nil_backtrace_wrapper = ExceptionWrapper.new(@cleaner, BadlyDefinedError.new)
nil_cleaner_wrapper = ExceptionWrapper.new(nil, BadlyDefinedError.new) nil_cleaner_wrapper = ExceptionWrapper.new(nil, BadlyDefinedError.new)