summaryrefslogtreecommitdiff
path: root/django/middleware/csrf.py
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2021-03-24 03:52:22 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-25 06:39:35 +0100
commit70332e6c431dc5988230dd3d91d3d8108b9aa0f0 (patch)
tree8b934e2c20c972a0f933b52b504ac30ac757e165 /django/middleware/csrf.py
parent5388ff2a52ec87dae6638f5c1b85d1580f02a526 (diff)
Refs #32579 -- Optimized good_hosts creation in CsrfViewMiddleware.process_view().
Diffstat (limited to 'django/middleware/csrf.py')
-rw-r--r--django/middleware/csrf.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py
index 2ee97ce8ce..c8114d5de5 100644
--- a/django/middleware/csrf.py
+++ b/django/middleware/csrf.py
@@ -330,11 +330,10 @@ class CsrfViewMiddleware(MiddlewareMixin):
except DisallowedHost:
pass
- # Create a list of all acceptable HTTP referers, including the
- # current host if it's permitted by ALLOWED_HOSTS.
- good_hosts = list(self.csrf_trusted_origins_hosts)
+ # Create an iterable of all acceptable HTTP referers.
+ good_hosts = self.csrf_trusted_origins_hosts
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):
reason = REASON_BAD_REFERER % referer.geturl()