aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2013-03-03 15:03:57 +1300
committerAldo Cortesi <aldo@nullcube.com>2013-03-03 15:03:57 +1300
commitcd4ed8530fa04fcbd54009e9db6ad9ea2518a10b (patch)
treeb12cf2bb02de5ab38194f1eca17c1303b968b3bc /netlib/http.py
parent2897ddfbee5ec3da72863cb8d5ee1370c9698f8a (diff)
downloadmitmproxy-cd4ed8530fa04fcbd54009e9db6ad9ea2518a10b.tar.gz
mitmproxy-cd4ed8530fa04fcbd54009e9db6ad9ea2518a10b.tar.bz2
mitmproxy-cd4ed8530fa04fcbd54009e9db6ad9ea2518a10b.zip
Check that hosts in parse_url do not contain NULL bytes.
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 c864f1de..1b03d330 100644
--- a/netlib/http.py
+++ b/netlib/http.py
@@ -18,7 +18,7 @@ def parse_url(url):
Checks that:
port is an integer
- host is a valid IDNA-encoded hostname
+ host is a valid IDNA-encoded hostname with no null-bytes
path is valid ASCII
"""
scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
@@ -43,6 +43,8 @@ def parse_url(url):
host.decode("idna")
except ValueError:
return None
+ if "\0" in host:
+ return None
try:
path.decode("ascii")
except ValueError: