mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #26971 -- Prevented crash with non-UTF-8 incoming PATH_INFO
Thanks Tim Graham and Loïc Bistuer for the reviews.
This commit is contained in:
@@ -33,12 +33,16 @@ class HandlerTests(SimpleTestCase):
|
||||
self.assertIsNotNone(handler._request_middleware)
|
||||
|
||||
def test_bad_path_info(self):
|
||||
"""Tests for bug #15672 ('request' referenced before assignment)"""
|
||||
"""
|
||||
A non-UTF-8 path populates PATH_INFO with an URL-encoded path and
|
||||
produces a 404.
|
||||
"""
|
||||
environ = RequestFactory().get('/').environ
|
||||
environ['PATH_INFO'] = b'\xed' if six.PY2 else '\xed'
|
||||
handler = WSGIHandler()
|
||||
response = handler(environ, lambda *a, **k: None)
|
||||
self.assertEqual(response.status_code, 400)
|
||||
# The path of the request will be encoded to '/%ED'.
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_non_ascii_query_string(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user