From 73396238e7218d3697884234fce74e604450bf4f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 18 Sep 2015 11:26:15 -0700 Subject: pull `normalize_encode_params` up `normalize_encode_params` is common to all parser code paths, so we can pull that up and always apply it before assigning the request parameters --- actionpack/lib/action_dispatch/http/request.rb | 4 ++-- actionpack/lib/action_dispatch/middleware/params_parser.rb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 232006895f..148ab7c3b8 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -349,9 +349,9 @@ module ActionDispatch def POST fetch_header("action_dispatch.request.request_parameters") do pr = parse_formatted_parameters(self, params_parsers) do |params| - Request::Utils.normalize_encode_params(super || {}) + super || {} end - self.request_parameters = pr + self.request_parameters = Request::Utils.normalize_encode_params(pr) end rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e raise ActionController::BadRequest.new(:request, e) diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb index a658a414a5..17524129d4 100644 --- a/actionpack/lib/action_dispatch/middleware/params_parser.rb +++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb @@ -21,8 +21,7 @@ module ActionDispatch DEFAULT_PARSERS = { Mime::JSON => lambda { |raw_post| data = ActiveSupport::JSON.decode(raw_post) - data = {:_json => data} unless data.is_a?(Hash) - Request::Utils.normalize_encode_params(data) + data.is_a?(Hash) ? data : {:_json => data} } } -- cgit v1.2.3