-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
[3.8] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (GH-25595) #25726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.8] bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (GH-25595) #25726
Changes from 1 commit
56cdbe0
957ee9d
9a1d1f7
ce95fae
94da00c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,6 +417,11 @@ def _checknetloc(netloc): | |
| raise ValueError("netloc '" + netloc + "' contains invalid " + | ||
| "characters under NFKC normalization") | ||
|
|
||
| def _remove_unsafe_bytes_from_url(url): | ||
| for b in _UNSAFE_URL_BYTES_TO_REMOVE: | ||
| url = url.replace(b, "") | ||
| return url | ||
|
|
||
| def urlsplit(url, scheme='', allow_fragments=True): | ||
| """Parse a URL into 5 components: | ||
| <scheme>://<netloc>/<path>?<query>#<fragment> | ||
|
|
@@ -446,6 +451,7 @@ def urlsplit(url, scheme='', allow_fragments=True): | |
| if '?' in url: | ||
| url, query = url.split('?', 1) | ||
| _checknetloc(netloc) | ||
| url = _remove_unsafe_bytes_from_url(url) | ||
|
||
| v = SplitResult('http', netloc, url, query, fragment) | ||
| _parse_cache[key] = v | ||
| return _coerce_result(v) | ||
|
|
@@ -460,8 +466,7 @@ 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, "") | ||
| url = _remove_unsafe_bytes_from_url(url) | ||
|
|
||
| if url[:2] == '//': | ||
| netloc, url = _splitnetloc(url, 2) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.