mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.7.x] Fixed #23638 -- Prevented crash while parsing invalid cookie content
Thanks Philip Gatt for the report and Tim Graham for the review.
Backport of 59d487e7fc from master.
This commit is contained in:
@@ -80,6 +80,16 @@ class HandlerTests(TestCase):
|
||||
# much more work than fixing #20557. Feel free to remove force_str()!
|
||||
self.assertEqual(request.COOKIES['want'], force_str("café"))
|
||||
|
||||
def test_invalid_unicode_cookie(self):
|
||||
"""
|
||||
Invalid cookie content should result in an absent cookie, but not in a
|
||||
crash while trying to decode it (#23638).
|
||||
"""
|
||||
environ = RequestFactory().get('/').environ
|
||||
environ['HTTP_COOKIE'] = 'x=W\x03c(h]\x8e'
|
||||
request = WSGIRequest(environ)
|
||||
self.assertEqual(request.COOKIES, {})
|
||||
|
||||
|
||||
class TransactionsPerRequestTests(TransactionTestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user