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:57:44 +0200 |
commit | 81fd7d9ccc3ab32c46e112957852778e8f30a0b6 (patch) | |
tree | 8267bfd9f2a74422a1b9957c02233f5f9a3f4e73 | |
parent | [3.9] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline ... (diff) | |
download | cpython-gentoo-3.6.13_p3.tar.gz cpython-gentoo-3.6.13_p3.tar.bz2 cpython-gentoo-3.6.13_p3.zip |
Fix urllib.parse sanitization for older <3.9 codegentoo-3.6.13_p3
-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 ce9acb2c72b..385dd9711d3 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -427,6 +427,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 @@ -456,9 +460,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 |