Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b496159

Browse files
committed
merge from 3.2
2 parents 0dea648 + b4bd4af commit b496159

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

Lib/test/test_urlparse.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ def test_RFC1808(self):
228228
#self.checkJoin(RFC1808_BASE, 'http:g', 'http:g')
229229
#self.checkJoin(RFC1808_BASE, 'http:', 'http:')
230230

231+
def test_RFC2368(self):
232+
# Issue 11467: path that starts with a number is not parsed correctly
233+
self.assertEqual(urllib.parse.urlparse('mailto:[email protected]'),
234+
('mailto', '', '[email protected]', '', '', ''))
235+
231236
def test_RFC2396(self):
232237
# cases from RFC 2396
233238

Lib/urllib/parse.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,17 @@ def urlsplit(url, scheme='', allow_fragments=True):
340340
v = SplitResult(scheme, netloc, url, query, fragment)
341341
_parse_cache[key] = v
342342
return _coerce_result(v)
343-
if url.endswith(':') or not url[i+1].isdigit():
344-
for c in url[:i]:
345-
if c not in scheme_chars:
346-
break
347-
else:
343+
for c in url[:i]:
344+
if c not in scheme_chars:
345+
break
346+
else:
347+
try:
348+
# make sure "url" is not actually a port number (in which case
349+
# "scheme" is really part of the path
350+
_testportnum = int(url[i+1:])
351+
except ValueError:
348352
scheme, url = url[:i].lower(), url[i+1:]
353+
349354
if url[:2] == '//':
350355
netloc, url = _splitnetloc(url, 2)
351356
if (('[' in netloc and ']' not in netloc) or

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ Core and Builtins
106106
Library
107107
-------
108108

109+
- Issue #11467: Fix urlparse behavior when handling urls which contains scheme
110+
specific part only digits. Patch by Santoso Wijaya.
111+
109112
- Issue #11474: Fix the bug with url2pathname() handling of '/C|/' on Windows.
110113
Patch by Santoso Wijaya.
111114

0 commit comments

Comments
 (0)