summaryrefslogtreecommitdiff
path: root/django/middleware/common.py
diff options
context:
space:
mode:
authorJake Howard <RealOrangeOne@users.noreply.github.com>2024-05-29 14:48:27 +0100
committerGitHub <noreply@github.com>2024-05-29 10:48:27 -0300
commitff308a06047cd60806d604a7cf612e5656ee2ac9 (patch)
treef2139fbf020cbdf33bad64a3377700623c18a44f /django/middleware/common.py
parent02dab94c7b8585c7ae3854465574d768e1df75d3 (diff)
Fixed 35467 -- Replaced urlparse with urlsplit where appropriate.
This work should not generate any change of functionality, and `urlsplit` is approximately 6x faster. Most use cases of `urlparse` didn't touch the path, so they can be converted to `urlsplit` without any issue. Most of those which do use `.path`, simply parse the URL, mutate the querystring, then put them back together, which is also fine (so long as urlunsplit is used).
Diffstat (limited to 'django/middleware/common.py')
-rw-r--r--django/middleware/common.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py
index 9f71b9d278..bf22d00f01 100644
--- a/django/middleware/common.py
+++ b/django/middleware/common.py
@@ -1,5 +1,5 @@
import re
-from urllib.parse import urlparse
+from urllib.parse import urlsplit
from django.conf import settings
from django.core.exceptions import PermissionDenied
@@ -171,7 +171,7 @@ class BrokenLinkEmailsMiddleware(MiddlewareMixin):
# The referer is equal to the current URL, ignoring the scheme (assumed
# to be a poorly implemented bot).
- parsed_referer = urlparse(referer)
+ parsed_referer = urlsplit(referer)
if parsed_referer.netloc in ["", domain] and parsed_referer.path == uri:
return True