Merge "middleware: return HTTPBadRequest when path is invalid"
This commit is contained in:
commit
062d04e685
@ -41,6 +41,13 @@ class VersionNegotiationFilter(wsgi.Middleware):
|
||||
return the correct API controller, otherwise, if we
|
||||
find an Accept: header, process it
|
||||
"""
|
||||
|
||||
# Make sure the request path is valid UTF-8
|
||||
try:
|
||||
req.path
|
||||
except UnicodeDecodeError:
|
||||
return webob.exc.HTTPBadRequest()
|
||||
|
||||
# See if a version identifier is in the URI passed to
|
||||
# us already. If so, simply return the right version
|
||||
# API controller
|
||||
|
@ -136,3 +136,12 @@ class VersionNegotiationMiddlewareTest(common.HeatTestCase):
|
||||
response = version_negotiation.process_request(request)
|
||||
|
||||
self.assertIsInstance(response, webob.exc.HTTPNotFound)
|
||||
|
||||
def test_invalid_utf8_path(self):
|
||||
version_negotiation = vn.VersionNegotiationFilter(
|
||||
self._version_controller_factory, None, None)
|
||||
request = webob.Request.blank('/%c0')
|
||||
|
||||
response = version_negotiation.process_request(request)
|
||||
|
||||
self.assertIsInstance(response, webob.exc.HTTPBadRequest)
|
||||
|
Loading…
x
Reference in New Issue
Block a user