File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -524,6 +524,11 @@ def test_urlsplit_attributes(self):
524524 self .assertEqual (p .port , 80 )
525525 self .assertEqual (p .geturl (), url )
526526
527+ # Verify an illegal port is returned as None
528+ url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag"
529+ p = urllib .parse .urlsplit (url )
530+ self .assertEqual (p .port , None )
531+
527532 def test_attributes_bad_port (self ):
528533 """Check handling of non-integer ports."""
529534 p = urllib .parse .urlsplit ("http://www.example.net:foo" )
Original file line number Diff line number Diff line change @@ -143,6 +143,9 @@ def port(self):
143143 port = self ._hostinfo [1 ]
144144 if port is not None :
145145 port = int (port , 10 )
146+ # Return None on an illegal port
147+ if not ( 0 <= port <= 65535 ):
148+ return None
146149 return port
147150
148151
Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ Core and Builtins
6767Library
6868-------
6969
70+ - Issue #14036: Add an additional check to validate that port in urlparse does
71+ not go in illegal range and returns None.
72+
7073- Issue #14875: Use float('inf') instead of float('1e66666') in the json module.
7174
7275- Issue #14426: Correct the Date format in Expires attribute of Set-Cookie
You can’t perform that action at this time.
0 commit comments