mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #20356 -- Prevented crash when HTTP_REFERER contains non-ascii
Thanks srusskih for the report and Aymeric Augustin for the review.
This commit is contained in:
@@ -22,7 +22,7 @@ from django.test.utils import override_settings
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.six.moves import xrange
|
||||
from django.utils.unittest import expectedFailure
|
||||
from django.utils.unittest import expectedFailure, skipIf
|
||||
|
||||
from transactions.tests import IgnorePendingDeprecationWarningsMixin
|
||||
|
||||
@@ -320,6 +320,14 @@ class BrokenLinkEmailsMiddlewareTest(TestCase):
|
||||
BrokenLinkEmailsMiddleware().process_response(self.req, self.resp)
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
@skipIf(six.PY3, "HTTP_REFERER is str type on Python 3")
|
||||
def test_404_error_nonascii_referrer(self):
|
||||
# Such referer strings should not happen, but anyway, if it happens,
|
||||
# let's not crash
|
||||
self.req.META['HTTP_REFERER'] = b'http://testserver/c/\xd0\xbb\xd0\xb8/'
|
||||
BrokenLinkEmailsMiddleware().process_response(self.req, self.resp)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
|
||||
|
||||
class ConditionalGetMiddlewareTest(TestCase):
|
||||
urls = 'middleware.cond_get_urls'
|
||||
|
||||
Reference in New Issue
Block a user