summaryrefslogtreecommitdiff
path: root/Lib/urlparse.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-05-19 17:12:17 +0300
committerEzio Melotti <ezio.melotti@gmail.com>2012-05-19 17:12:17 +0300
commit6d9c1b1617b30ee24eaa358f4142706148d21922 (patch)
treeb0d0a64a88c1a77eda61fbaf79e2a6036a922c64 /Lib/urlparse.py
parent618802d55e19c1f2da28c9409256a7f2fbf59e99 (diff)
downloadcpython-git-6d9c1b1617b30ee24eaa358f4142706148d21922.tar.gz
#14072: Fix parsing of tel URIs in urlparse by making the check for ports stricter.
Diffstat (limited to 'Lib/urlparse.py')
-rw-r--r--Lib/urlparse.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index 32eebe69bd..4c57725ce3 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -185,12 +185,12 @@ def urlsplit(url, scheme='', allow_fragments=True):
if c not in scheme_chars:
break
else:
- try:
- # make sure "url" is not actually a port number (in which case
- # "scheme" is really part of the path
- _testportnum = int(url[i+1:])
- except ValueError:
- scheme, url = url[:i].lower(), url[i+1:]
+ # 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
if url[:2] == '//':
netloc, url = _splitnetloc(url, 2)