aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-09-18 11:26:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-09-18 11:26:15 -0700
commit73396238e7218d3697884234fce74e604450bf4f (patch)
treeae6e7e6da3af94c211625022d09391149396b719 /actionpack
parent93a391e7863102a77991fc019bb5b9b4158ec759 (diff)
downloadrails-73396238e7218d3697884234fce74e604450bf4f.tar.gz
rails-73396238e7218d3697884234fce74e604450bf4f.tar.bz2
rails-73396238e7218d3697884234fce74e604450bf4f.zip
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
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb4
-rw-r--r--actionpack/lib/action_dispatch/middleware/params_parser.rb3
2 files changed, 3 insertions, 4 deletions
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}
}
}