diff options
author | Tim Graham <timograham@gmail.com> | 2019-10-18 09:07:20 -0400 |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2019-10-18 06:51:12 -0700 |
commit | 94f32caf49627bbc30e188af49f8ee69c9850ad9 (patch) | |
tree | e034c70610185281f4ac3658bdb3d1e41b07bf71 /Lib/urllib/parse.py | |
parent | de812682a674cdf2bac0f9547200f107069781ad (diff) | |
download | cpython-git-backport-5a88d50-3.8.tar.gz |
[3.8] bpo-27657: Fix urlparse() with numeric paths (GH-661)backport-5a88d50-3.8
* bpo-27657: Fix urlparse() with numeric paths
Revert parsing decision from bpo-754016 in favor of the documented
consensus in bpo-16932 of how to treat strings without a // to
designate the netloc.
* bpo-22891: Remove urlsplit() optimization for 'http' prefixed inputs.
(cherry picked from commit 5a88d50ff013a64fbdb25b877c87644a9034c969)
Co-authored-by: Tim Graham <timograham@gmail.com>
Diffstat (limited to 'Lib/urllib/parse.py')
-rw-r--r-- | Lib/urllib/parse.py | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index b6608783a8..d497925b94 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -431,31 +431,11 @@ def urlsplit(url, scheme='', allow_fragments=True): netloc = query = fragment = '' i = url.find(':') if i > 0: - if url[:i] == 'http': # optimize the common case - url = url[i+1:] - if url[:2] == '//': - netloc, url = _splitnetloc(url, 2) - if (('[' in netloc and ']' not in netloc) or - (']' in netloc and '[' not in netloc)): - raise ValueError("Invalid IPv6 URL") - if allow_fragments and '#' in url: - url, fragment = url.split('#', 1) - if '?' in url: - url, query = url.split('?', 1) - _checknetloc(netloc) - v = SplitResult('http', netloc, url, query, fragment) - _parse_cache[key] = v - return _coerce_result(v) for c in url[:i]: if c not in scheme_chars: break else: - # make sure "url" is not actually a port number (in which case - # "scheme" is really part of the path) - rest = url[i+1:] - if not rest or any(c not in '0123456789' for c in rest): - # not a port number - scheme, url = url[:i].lower(), rest + scheme, url = url[:i].lower(), url[i+1:] if url[:2] == '//': netloc, url = _splitnetloc(url, 2) |