mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #25302 -- Prevented BrokenLinkEmailsMiddleware from reporting 404s when Referer = URL.
This commit is contained in:
committed by
Tim Graham
parent
d3fdaf907d
commit
4ce433e811
@@ -375,6 +375,24 @@ class BrokenLinkEmailsMiddlewareTest(SimpleTestCase):
|
||||
SubclassedMiddleware().process_response(self.req, self.resp)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
|
||||
def test_referer_equal_to_requested_url(self):
|
||||
"""
|
||||
Some bots set the referer to the current URL to avoid being blocked by
|
||||
an referer check (#25302).
|
||||
"""
|
||||
self.req.META['HTTP_REFERER'] = self.req.path
|
||||
BrokenLinkEmailsMiddleware().process_response(self.req, self.resp)
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
# URL with scheme and domain should also be ignored
|
||||
self.req.META['HTTP_REFERER'] = 'http://testserver%s' % self.req.path
|
||||
BrokenLinkEmailsMiddleware().process_response(self.req, self.resp)
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
def test_referer_equal_to_requested_url_on_another_domain(self):
|
||||
self.req.META['HTTP_REFERER'] = 'http://anotherserver%s' % self.req.path
|
||||
BrokenLinkEmailsMiddleware().process_response(self.req, self.resp)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF='middleware.cond_get_urls')
|
||||
class ConditionalGetMiddlewareTest(SimpleTestCase):
|
||||
|
||||
Reference in New Issue
Block a user