cpython: 988903cf24c5 (original) (raw)
Mercurial > cpython
changeset 77119:988903cf24c5 2.7
Issue #14036: return None when port in urlparse cross 65535 [#14036]
Senthil Kumaran senthil@uthcode.com | |
---|---|
date | Thu, 24 May 2012 21:54:34 +0800 |
parents | 290d970c011d |
children | 5107782c4dd8 |
files | Lib/test/test_urlparse.py Lib/urlparse.py Misc/NEWS |
diffstat | 3 files changed, 13 insertions(+), 3 deletions(-)[+] [-] Lib/test/test_urlparse.py 5 Lib/urlparse.py 8 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -437,6 +437,11 @@ class UrlParseTestCase(unittest.TestCase self.assertEqual(p.port, 80) self.assertEqual(p.geturl(), url)
# Verify an illegal port of value greater than 65535 is set as None[](#l1.7)
url = "http://www.python.org:65536"[](#l1.8)
p = urlparse.urlsplit(url)[](#l1.9)
self.assertEqual(p.port, None)[](#l1.10)
+ def test_issue14072(self): p1 = urlparse.urlsplit('tel:+31-641044153') self.assertEqual(p1.scheme, 'tel')
--- a/Lib/urlparse.py +++ b/Lib/urlparse.py @@ -97,9 +97,11 @@ class ResultMixin(object): netloc = self.netloc.split('@')[-1].split(']')[-1] if ':' in netloc: port = netloc.split(':')[1]
return int(port, 10)[](#l2.7)
else:[](#l2.8)
return None[](#l2.9)
port = int(port, 10)[](#l2.10)
# verify legal port[](#l2.11)
if (0 <= port <= 65535):[](#l2.12)
return port[](#l2.13)
return None[](#l2.14)
from collections import namedtuple
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -64,6 +64,9 @@ Core and Builtins Library ------- +- Issue #14036: Add an additional check to validate that port in urlparse does