Merge pull request #2739 from pallets/2735-abort-debug

Only trap key errors by default in debug, not all BadRequest errors
This commit is contained in:
David Lord 2018-04-28 07:01:42 -07:00 committed by GitHub
commit 4c8ec8f555
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 8 deletions

View file

@ -1663,8 +1663,14 @@ class Flask(_PackageBoundObject):
trap_bad_request = self.config['TRAP_BAD_REQUEST_ERRORS']
# if unset, trap based on debug mode
if (trap_bad_request is None and self.debug) or trap_bad_request:
# if unset, trap key errors in debug mode
if (
trap_bad_request is None and self.debug
and isinstance(e, BadRequestKeyError)
):
return True
if trap_bad_request:
return isinstance(e, BadRequest)
return False