Fix handling of ParseError in controllers
It regressed in #34894, which moved the rescue to the wrong method. `_wrapper_enabled?` can access the parameters and the exception will raise there before even entering `_perfomr_parameter_wrapping`. Closes #38285.
This commit is contained in:
parent
bcf3752247
commit
7d2d00a334
@ -281,7 +281,10 @@ def _wrapper_enabled?
|
||||
return false unless request.has_content_type?
|
||||
|
||||
ref = request.content_mime_type.ref
|
||||
|
||||
_wrapper_formats.include?(ref) && _wrapper_key && !request.parameters.key?(_wrapper_key)
|
||||
rescue ActionDispatch::Http::Parameters::ParseError
|
||||
false
|
||||
end
|
||||
|
||||
def _perform_parameter_wrapping
|
||||
@ -295,8 +298,6 @@ def _perform_parameter_wrapping
|
||||
|
||||
# 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
|
||||
|
@ -33,6 +33,8 @@ class ResourceUnavailable < StandardError
|
||||
class ResourceUnavailableToRescueAsString < StandardError
|
||||
end
|
||||
|
||||
wrap_parameters format: :json
|
||||
|
||||
# We use a fully qualified name in some strings, and a relative constant
|
||||
# name in some other to test correct handling of both cases.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user