diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2019-01-09 01:30:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-09 01:30:28 +0100 |
commit | ee3ebc90983857f5ace8e0fea787c45e0192f144 (patch) | |
tree | 4af247c983cb6989f551aaff3f6da56e349d0d73 /actionpack/lib/action_controller/metal | |
parent | b03d493cf61f37abe7dc0539aee1985b6a9eea63 (diff) | |
parent | a37cf8d383147a1e6b5f71dfe214d2e03d177872 (diff) | |
download | rails-ee3ebc90983857f5ace8e0fea787c45e0192f144.tar.gz rails-ee3ebc90983857f5ace8e0fea787c45e0192f144.tar.bz2 rails-ee3ebc90983857f5ace8e0fea787c45e0192f144.zip |
Merge pull request #34894 from hahmed/tames-params-wrapper-errors
Capture parsing errors only for ActionController::ParamsWrapper#process_actions
Diffstat (limited to 'actionpack/lib/action_controller/metal')
-rw-r--r-- | actionpack/lib/action_controller/metal/params_wrapper.rb | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb index 7361946de5..09716f7588 100644 --- a/actionpack/lib/action_controller/metal/params_wrapper.rb +++ b/actionpack/lib/action_controller/metal/params_wrapper.rb @@ -241,22 +241,8 @@ module ActionController # Performs parameters wrapping upon the request. Called automatically # by the metal call stack. def process_action(*args) - if _wrapper_enabled? - wrapped_hash = _wrap_parameters request.request_parameters - wrapped_keys = request.request_parameters.keys - wrapped_filtered_hash = _wrap_parameters request.filtered_parameters.slice(*wrapped_keys) - - # This will make the wrapped hash accessible from controller and view. - request.parameters.merge! wrapped_hash - request.request_parameters.merge! wrapped_hash - - # This will display the wrapped hash in the log file. - request.filtered_parameters.merge! wrapped_filtered_hash - end - ensure - # NOTE: Rescues all exceptions so they - # may be caught in ActionController::Rescue. - return super + _perform_parameter_wrapping if _wrapper_enabled? + super end private @@ -292,5 +278,20 @@ module ActionController ref = request.content_mime_type.ref _wrapper_formats.include?(ref) && _wrapper_key && !request.parameters.key?(_wrapper_key) end + + def _perform_parameter_wrapping + wrapped_hash = _wrap_parameters request.request_parameters + wrapped_keys = request.request_parameters.keys + wrapped_filtered_hash = _wrap_parameters request.filtered_parameters.slice(*wrapped_keys) + + # This will make the wrapped hash accessible from controller and view. + request.parameters.merge! wrapped_hash + request.request_parameters.merge! wrapped_hash + + # This will display the wrapped hash in the log file. + request.filtered_parameters.merge! wrapped_filtered_hash + rescue ActionDispatch::Http::Parameters::ParseError + # swallow parse error exception + end end end |