mirror of
https://github.com/django/django.git
synced 2025-10-17 22:07:29 +00:00
Fixed #25302 (again) -- Ignored scheme when checking for bad referers.
The check introduced in 4ce433e
was too strict in real life. The poorly
implemented bots this patch attempted to ignore are sloppy when it comes
to http vs. https.
This commit is contained in:
parent
cc2ca9c550
commit
11f10b70f3
2 changed files with 20 additions and 6 deletions
|
@ -383,11 +383,20 @@ class BrokenLinkEmailsMiddlewareTest(SimpleTestCase):
|
|||
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)
|
||||
|
||||
# URL with a different scheme should be ignored as well because bots
|
||||
# tend to use http:// in referers even when browsing HTTPS websites.
|
||||
self.req.META['HTTP_X_PROTO'] = 'https'
|
||||
self.req.META['SERVER_PORT'] = 443
|
||||
with self.settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_PROTO', 'https')):
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue