Handle errors during create_url_adapter
If create_url_adapter raises (which it can if werkzeug cannot bind environment, for example on non-ASCII Host header), we handle it as other routing exceptions rather than raising through. ref https://github.com/pallets/werkzeug/issues/640
This commit is contained in:
parent
339419117f
commit
ed9775fb77
2 changed files with 30 additions and 2 deletions
|
|
@ -282,7 +282,11 @@ class RequestContext(object):
|
|||
if request is None:
|
||||
request = app.request_class(environ)
|
||||
self.request = request
|
||||
self.url_adapter = app.create_url_adapter(self.request)
|
||||
self.url_adapter = None
|
||||
try:
|
||||
self.url_adapter = app.create_url_adapter(self.request)
|
||||
except HTTPException as e:
|
||||
self.request.routing_exception = e
|
||||
self.flashes = None
|
||||
self.session = session
|
||||
|
||||
|
|
@ -305,7 +309,8 @@ class RequestContext(object):
|
|||
# functions.
|
||||
self._after_request_functions = []
|
||||
|
||||
self.match_request()
|
||||
if self.url_adapter is not None:
|
||||
self.match_request()
|
||||
|
||||
def _get_g(self):
|
||||
return _app_ctx_stack.top.g
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue