Skip to content

Commit aa0526d

Browse files
authored
Implement the fix from the upstream python/cpython#25595
1 parent bd43cf1 commit aa0526d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Src/StdLib/Lib/urlparse.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
'0123456789'
6363
'+-.')
6464

65+
# Unsafe bytes to be removed per WHATWG spec
66+
_UNSAFE_URL_BYTES_TO_REMOVE = ['\t', '\r', '\n']
67+
6568
MAX_CACHE_SIZE = 20
6669
_parse_cache = {}
6770

@@ -227,6 +230,9 @@ def urlsplit(url, scheme='', allow_fragments=True):
227230
# not a port number
228231
scheme, url = url[:i].lower(), rest
229232

233+
for b in _UNSAFE_URL_BYTES_TO_REMOVE:
234+
url = url.replace(b, "")
235+
230236
if url[:2] == '//':
231237
netloc, url = _splitnetloc(url, 2)
232238
if (('[' in netloc and ']' not in netloc) or

0 commit comments

Comments
 (0)