diff --git a/Src/StdLib/Lib/urlparse.py b/Src/StdLib/Lib/urlparse.py index f2b16e318..cca915e44 100644 --- a/Src/StdLib/Lib/urlparse.py +++ b/Src/StdLib/Lib/urlparse.py @@ -62,6 +62,9 @@ '0123456789' '+-.') +# Unsafe bytes to be removed per WHATWG spec +_UNSAFE_URL_BYTES_TO_REMOVE = ['\t', '\r', '\n'] + MAX_CACHE_SIZE = 20 _parse_cache = {} @@ -227,6 +230,9 @@ 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