summaryrefslogtreecommitdiff
path: root/django/contrib/auth/views.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/contrib/auth/views.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/contrib/auth/views.py')
-rw-r--r--django/contrib/auth/views.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index 9a6d18bcd2..a18cfdb347 100644
--- a/django/contrib/auth/views.py
+++ b/django/contrib/auth/views.py
@@ -1,4 +1,4 @@
-from urllib.parse import urlparse, urlunparse
+from urllib.parse import urlsplit, urlunsplit
from django.conf import settings
@@ -183,13 +183,13 @@ def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_N
"""
resolved_url = resolve_url(login_url or settings.LOGIN_URL)
- login_url_parts = list(urlparse(resolved_url))
+ login_url_parts = list(urlsplit(resolved_url))
if redirect_field_name:
- querystring = QueryDict(login_url_parts[4], mutable=True)
+ querystring = QueryDict(login_url_parts[3], mutable=True)
querystring[redirect_field_name] = next
- login_url_parts[4] = querystring.urlencode(safe="/")
+ login_url_parts[3] = querystring.urlencode(safe="/")
- return HttpResponseRedirect(urlunparse(login_url_parts))
+ return HttpResponseRedirect(urlunsplit(login_url_parts))
# Class-based password reset views