diff options
| author | Jake Howard <RealOrangeOne@users.noreply.github.com> | 2024-05-29 14:48:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-29 10:48:27 -0300 |
| commit | ff308a06047cd60806d604a7cf612e5656ee2ac9 (patch) | |
| tree | f2139fbf020cbdf33bad64a3377700623c18a44f /django/http | |
| parent | 02dab94c7b8585c7ae3854465574d768e1df75d3 (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/http')
| -rw-r--r-- | django/http/response.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/http/response.py b/django/http/response.py index eecd972cd6..0d756403db 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -9,7 +9,7 @@ import time import warnings from email.header import Header from http.client import responses -from urllib.parse import urlparse +from urllib.parse import urlsplit from asgiref.sync import async_to_sync, sync_to_async @@ -616,7 +616,7 @@ class HttpResponseRedirectBase(HttpResponse): def __init__(self, redirect_to, *args, **kwargs): super().__init__(*args, **kwargs) self["Location"] = iri_to_uri(redirect_to) - parsed = urlparse(str(redirect_to)) + parsed = urlsplit(str(redirect_to)) if parsed.scheme and parsed.scheme not in self.allowed_schemes: raise DisallowedRedirect( "Unsafe redirect to URL with protocol '%s'" % parsed.scheme |
