aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/request.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-09-18 11:34:54 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-09-18 11:34:54 -0700
commit1555ae9be1a74a869e4b238e00b820799dab8218 (patch)
tree03cb1e02efe18f3edfef9c25c0a8fad3193a2c04 /actionpack/lib/action_dispatch/http/request.rb
parent73396238e7218d3697884234fce74e604450bf4f (diff)
downloadrails-1555ae9be1a74a869e4b238e00b820799dab8218.tar.gz
rails-1555ae9be1a74a869e4b238e00b820799dab8218.tar.bz2
rails-1555ae9be1a74a869e4b238e00b820799dab8218.zip
only wrap the strategy with exception handling
we need to be more specific about exception handling when dealing with the parse strategies. The calls to `return yield` can also raise an exception, but we don't want to handle that in *this* code.
Diffstat (limited to 'actionpack/lib/action_dispatch/http/request.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index 148ab7c3b8..ea083425ba 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -353,6 +353,9 @@ module ActionDispatch
end
self.request_parameters = Request::Utils.normalize_encode_params(pr)
end
+ rescue ParamsParser::ParseError # one of the parse strategies blew up
+ self.request_parameters = Request::Utils.normalize_encode_params(super || {})
+ raise
rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e
raise ActionController::BadRequest.new(:request, e)
end
@@ -402,16 +405,14 @@ module ActionDispatch
strategy = parsers.fetch(request.content_mime_type) { return yield }
- strategy.call(request.raw_post)
-
- rescue Rack::QueryParser::InvalidParameterError
- raise
- rescue => e # JSON or Ruby code block errors
- my_logger = logger || ActiveSupport::Logger.new($stderr)
- my_logger.debug "Error occurred while parsing request parameters.\nContents:\n\n#{request.raw_post}"
- request.request_parameters = {}
+ begin
+ strategy.call(request.raw_post)
+ rescue => e # JSON or Ruby code block errors
+ my_logger = logger || ActiveSupport::Logger.new($stderr)
+ my_logger.debug "Error occurred while parsing request parameters.\nContents:\n\n#{request.raw_post}"
- raise ParamsParser::ParseError.new(e.message, e)
+ raise ParamsParser::ParseError.new(e.message, e)
+ end
end
end
end