don't clear BadRequestKeyError args

This commit is contained in:
David Lord 2019-06-26 14:32:20 -07:00
parent 31d3c7e719
commit 871e6d6a9d
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
3 changed files with 16 additions and 6 deletions

View File

@ -1,5 +1,15 @@
.. currentmodule:: flask
Version 1.0.4
-------------
Unreleased
- The key information for ``BadRequestKeyError`` is no longer cleared
outside debug mode, so error handlers can still access it. This
requires upgrading to Werkzeug 0.15.5. :issue:`3249`
Version 1.0.3
-------------

View File

@ -10,7 +10,7 @@
:license: BSD-3-Clause
"""
__version__ = '1.0.3'
__version__ = '1.0.4.dev'
# utilities we import from Werkzeug and Jinja2 that are unused
# in the module but are exported as public interface.

View File

@ -1724,14 +1724,14 @@ class Flask(_PackageBoundObject):
if isinstance(e, BadRequestKeyError):
if self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]:
e.show_exception = True
# Werkzeug < 0.15 doesn't add the KeyError to the 400
# message, add it in manually.
description = e.get_description()
if e.args[0] not in description:
# TODO: clean up once Werkzeug >= 0.15.5 is required
if e.args[0] not in e.get_description():
e.description = "KeyError: '{}'".format(*e.args)
else:
# Werkzeug >= 0.15 does add it, remove it in production
elif not hasattr(BadRequestKeyError, "show_exception"):
e.args = ()
if isinstance(e, HTTPException) and not self.trap_http_exception(e):