mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Issue #14036: return None when port in urlparse cross 65535
This commit is contained in:
parent
346c5de08e
commit
2fc5a50809
3 changed files with 11 additions and 0 deletions
|
@ -524,6 +524,11 @@ class UrlParseTestCase(unittest.TestCase):
|
||||||
self.assertEqual(p.port, 80)
|
self.assertEqual(p.port, 80)
|
||||||
self.assertEqual(p.geturl(), url)
|
self.assertEqual(p.geturl(), url)
|
||||||
|
|
||||||
|
# Verify an illegal port is returned as None
|
||||||
|
url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag"
|
||||||
|
p = urllib.parse.urlsplit(url)
|
||||||
|
self.assertEqual(p.port, None)
|
||||||
|
|
||||||
def test_attributes_bad_port(self):
|
def test_attributes_bad_port(self):
|
||||||
"""Check handling of non-integer ports."""
|
"""Check handling of non-integer ports."""
|
||||||
p = urllib.parse.urlsplit("http://www.example.net:foo")
|
p = urllib.parse.urlsplit("http://www.example.net:foo")
|
||||||
|
|
|
@ -143,6 +143,9 @@ class _NetlocResultMixinBase(object):
|
||||||
port = self._hostinfo[1]
|
port = self._hostinfo[1]
|
||||||
if port is not None:
|
if port is not None:
|
||||||
port = int(port, 10)
|
port = int(port, 10)
|
||||||
|
# Return None on an illegal port
|
||||||
|
if not ( 0 <= port <= 65535):
|
||||||
|
return None
|
||||||
return port
|
return port
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #14036: Add an additional check to validate that port in urlparse does
|
||||||
|
not go in illegal range and returns None.
|
||||||
|
|
||||||
- Issue #14875: Use float('inf') instead of float('1e66666') in the json module.
|
- Issue #14875: Use float('inf') instead of float('1e66666') in the json module.
|
||||||
|
|
||||||
- Issue #14426: Correct the Date format in Expires attribute of Set-Cookie
|
- Issue #14426: Correct the Date format in Expires attribute of Set-Cookie
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue