Merge branch '1.0-maintenance'

This commit is contained in:
David Lord 2019-01-05 15:12:17 -08:00
commit f7d50d4b67
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
10 changed files with 43 additions and 85 deletions

View file

@ -1698,16 +1698,17 @@ class Flask(_PackageBoundObject):
# we cannot prevent users from trashing it themselves in a custom
# trap_http_exception method so that's their fault then.
# MultiDict passes the key to the exception, but that's ignored
# when generating the response message. Set an informative
# description for key errors in debug mode or when trapping errors.
if (
(self.debug or self.config['TRAP_BAD_REQUEST_ERRORS'])
and isinstance(e, BadRequestKeyError)
# only set it if it's still the default description
and e.description is BadRequestKeyError.description
):
e.description = "KeyError: '{0}'".format(*e.args)
if isinstance(e, BadRequestKeyError):
if self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]:
# 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:
e.description = "KeyError: '{}'".format(*e.args)
else:
# Werkzeug >= 0.15 does add it, remove it in production
e.args = ()
if isinstance(e, HTTPException) and not self.trap_http_exception(e):
return self.handle_http_exception(e)

View file

@ -370,7 +370,7 @@ class ScriptInfo(object):
app = call_factory(self, self.create_app)
else:
if self.app_import_path:
path, name = (self.app_import_path.split(':', 1) + [None])[:2]
path, name = (re.split(r':(?![\\/])', self.app_import_path, 1) + [None])[:2]
import_name = prepare_import(path)
app = locate_app(self, import_name, name)
else: