mirror of https://github.com/django/django.git
Refs #32579 -- Optimized good_hosts creation in CsrfViewMiddleware.process_view().
This commit is contained in:
parent
5388ff2a52
commit
70332e6c43
|
@ -330,11 +330,10 @@ class CsrfViewMiddleware(MiddlewareMixin):
|
||||||
except DisallowedHost:
|
except DisallowedHost:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create a list of all acceptable HTTP referers, including the
|
# Create an iterable of all acceptable HTTP referers.
|
||||||
# current host if it's permitted by ALLOWED_HOSTS.
|
good_hosts = self.csrf_trusted_origins_hosts
|
||||||
good_hosts = list(self.csrf_trusted_origins_hosts)
|
|
||||||
if good_referer is not None:
|
if good_referer is not None:
|
||||||
good_hosts.append(good_referer)
|
good_hosts = (*good_hosts, good_referer)
|
||||||
|
|
||||||
if not any(is_same_domain(referer.netloc, host) for host in good_hosts):
|
if not any(is_same_domain(referer.netloc, host) for host in good_hosts):
|
||||||
reason = REASON_BAD_REFERER % referer.geturl()
|
reason = REASON_BAD_REFERER % referer.geturl()
|
||||||
|
|
Loading…
Reference in New Issue