aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-05-02 17:56:49 +0200
committerMichał Górny <mgorny@gentoo.org>2021-05-02 17:56:49 +0200
commit9a43667f46496c33b2c20bbfdd05f70ec7d8de59 (patch)
treed7b44c45c580d157137458df14abde288ea88926
parentbpo-36384: Leading zeros in IPv4 addresses are no longer tolerated (GH-25099)... (diff)
downloadcpython-gentoo-3.8.9_p2.tar.gz
cpython-gentoo-3.8.9_p2.tar.bz2
cpython-gentoo-3.8.9_p2.zip
Fix urllib.parse sanitization for older <3.9 codegentoo-3.8.9_p2
-rw-r--r--Lib/urllib/parse.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index a4808c5bb8a..c2a8f20afdc 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -432,6 +432,10 @@ def urlsplit(url, scheme='', allow_fragments=True):
if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth
clear_cache()
netloc = query = fragment = ''
+
+ for b in _UNSAFE_URL_BYTES_TO_REMOVE:
+ url = url.replace(b, "")
+
i = url.find(':')
if i > 0:
if url[:i] == 'http': # optimize the common case
@@ -460,9 +464,6 @@ def urlsplit(url, scheme='', allow_fragments=True):
# not a port number
scheme, url = url[:i].lower(), rest
- for b in _UNSAFE_URL_BYTES_TO_REMOVE:
- url = url.replace(b, "")
-
if url[:2] == '//':
netloc, url = _splitnetloc(url, 2)
if (('[' in netloc and ']' not in netloc) or