aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2013-03-03 15:08:17 +1300
committerAldo Cortesi <aldo@nullcube.com>2013-03-03 15:08:17 +1300
commit7b9300743e879a8a2e35f5786b23a17261350ff9 (patch)
treecb8553d292c44201f9afa0402e86648b70917481 /netlib/http.py
parentcd4ed8530fa04fcbd54009e9db6ad9ea2518a10b (diff)
downloadmitmproxy-7b9300743e879a8a2e35f5786b23a17261350ff9.tar.gz
mitmproxy-7b9300743e879a8a2e35f5786b23a17261350ff9.tar.bz2
mitmproxy-7b9300743e879a8a2e35f5786b23a17261350ff9.zip
More parse_url solidification: check that port is in range 0-65535
Diffstat (limited to 'netlib/http.py')
-rw-r--r--netlib/http.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/netlib/http.py b/netlib/http.py
index 1b03d330..5628dd4d 100644
--- a/netlib/http.py
+++ b/netlib/http.py
@@ -17,7 +17,7 @@ def parse_url(url):
Returns a (scheme, host, port, path) tuple, or None on error.
Checks that:
- port is an integer
+ port is an integer 0-65535
host is a valid IDNA-encoded hostname with no null-bytes
path is valid ASCII
"""
@@ -49,6 +49,8 @@ def parse_url(url):
path.decode("ascii")
except ValueError:
return None
+ if not 0 <= port <= 65535:
+ return None
return scheme, host, port, path