diff options
author | Eugene Kenny <elkenny@gmail.com> | 2017-06-25 02:13:05 +0100 |
---|---|---|
committer | Eugene Kenny <elkenny@gmail.com> | 2017-06-25 02:13:05 +0100 |
commit | ab491134a355257eec4730c48977b618c04549a7 (patch) | |
tree | 87295605991c9c3cd547ebce3e45eaef58ea7550 /actionpack/lib/action_controller/metal | |
parent | 98d12f1ef31014287c897fc60df4e1af70781ca3 (diff) | |
download | rails-ab491134a355257eec4730c48977b618c04549a7.tar.gz rails-ab491134a355257eec4730c48977b618c04549a7.tar.bz2 rails-ab491134a355257eec4730c48977b618c04549a7.zip |
Don't wrap parameters if query parameter exists
We want to avoid overwriting a query parameter with the wrapped
parameters hash. Previously this was implemented by merging the wrapped
parameters at the root level if the key already existed, which was
effectively a no-op. The query parameter was still overwritten in the
filtered parameters hash, however.
We can fix that discrepancy with a simpler implementation and less
unnecessary work by skipping parameter wrapping entirely if the key was
sent as a query parameter.
Diffstat (limited to 'actionpack/lib/action_controller/metal')
-rw-r--r-- | actionpack/lib/action_controller/metal/params_wrapper.rb | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb index 44151c9f71..818af549eb 100644 --- a/actionpack/lib/action_controller/metal/params_wrapper.rb +++ b/actionpack/lib/action_controller/metal/params_wrapper.rb @@ -232,12 +232,7 @@ module ActionController # by the metal call stack. def process_action(*args) if _wrapper_enabled? - if request.parameters[_wrapper_key].present? - wrapped_hash = _extract_parameters(request.parameters) - else - wrapped_hash = _wrap_parameters request.request_parameters - end - + wrapped_hash = _wrap_parameters request.request_parameters wrapped_keys = request.request_parameters.keys wrapped_filtered_hash = _wrap_parameters request.filtered_parameters.slice(*wrapped_keys) @@ -282,7 +277,7 @@ module ActionController return false unless request.has_content_type? ref = request.content_mime_type.ref - _wrapper_formats.include?(ref) && _wrapper_key && !request.request_parameters.key?(_wrapper_key) + _wrapper_formats.include?(ref) && _wrapper_key && !request.parameters.key?(_wrapper_key) end end end |