cpython: b4d257c64db7 (original) (raw)
Mercurial > cpython
changeset 77121:b4d257c64db7
Issue #14036: return None when port in urlparse cross 65535 [#14036]
Senthil Kumaran senthil@uthcode.com | |
---|---|
date | Thu, 24 May 2012 21:57:38 +0800 |
parents | f4f2139202c5(current diff)d769e64aed79(diff) |
children | f27e098a774a |
files | Misc/NEWS |
diffstat | 3 files changed, 11 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_urlparse.py 5 Lib/urllib/parse.py 3 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -524,6 +524,11 @@ class UrlParseTestCase(unittest.TestCase self.assertEqual(p.port, 80) self.assertEqual(p.geturl(), url)
# Verify an illegal port is returned as None[](#l1.7)
url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag"[](#l1.8)
p = urllib.parse.urlsplit(url)[](#l1.9)
self.assertEqual(p.port, None)[](#l1.10)
+ def test_attributes_bad_port(self): """Check handling of non-integer ports.""" p = urllib.parse.urlsplit("http://www.example.net:foo")[](#l1.14)
--- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -143,6 +143,9 @@ class _NetlocResultMixinBase(object): port = self._hostinfo[1] if port is not None: port = int(port, 10)
# Return None on an illegal port[](#l2.7)
if not ( 0 <= port <= 65535):[](#l2.8)
return None[](#l2.9) return port[](#l2.10)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -42,6 +42,9 @@ Core and Builtins Library ------- +- Issue #14036: Add an additional check to validate that port in urlparse does