summaryrefslogtreecommitdiff
path: root/Lib/urlparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/urlparse.py')
-rw-r--r--Lib/urlparse.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index 4c57725ce3..8a20756503 100644
--- 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)
- else:
- return None
+ port = int(port, 10)
+ # verify legal port
+ if (0 <= port <= 65535):
+ return port
+ return None
from collections import namedtuple