diff options
author | Michał Górny <mgorny@gentoo.org> | 2021-05-02 17:56:49 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2021-05-02 17:56:49 +0200 |
commit | 9a43667f46496c33b2c20bbfdd05f70ec7d8de59 (patch) | |
tree | d7b44c45c580d157137458df14abde288ea88926 | |
parent | bpo-36384: Leading zeros in IPv4 addresses are no longer tolerated (GH-25099)... (diff) | |
download | cpython-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.py | 7 |
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 |