aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2013-01-05 20:06:55 +1300
committerAldo Cortesi <aldo@nullcube.com>2013-01-05 20:06:55 +1300
commitd3b46feb6011c106b42d297b1a4807d187991345 (patch)
tree13d8dfa45cbec811a15fbe8b7a54e0445bae7ca9
parentddc08efde1a5132734f1f06481a97e484cc368e3 (diff)
downloadmitmproxy-d3b46feb6011c106b42d297b1a4807d187991345.tar.gz
mitmproxy-d3b46feb6011c106b42d297b1a4807d187991345.tar.bz2
mitmproxy-d3b46feb6011c106b42d297b1a4807d187991345.zip
Handle non-integer port error in parse_init_connect correctly
-rw-r--r--netlib/http.py5
-rw-r--r--test/test_http.py1
2 files changed, 5 insertions, 1 deletions
diff --git a/netlib/http.py b/netlib/http.py
index 3f730a1a..076baf87 100644
--- a/netlib/http.py
+++ b/netlib/http.py
@@ -189,7 +189,10 @@ def parse_init_connect(line):
host, port = url.split(":")
except ValueError:
return None
- port = int(port)
+ try:
+ port = int(port)
+ except ValueError:
+ return None
return host, port, httpversion
diff --git a/test/test_http.py b/test/test_http.py
index a6161fbc..ed16fb4a 100644
--- a/test/test_http.py
+++ b/test/test_http.py
@@ -139,6 +139,7 @@ def test_parse_init_connect():
assert not http.parse_init_connect("GET host.com:443 HTTP/1.0")
assert not http.parse_init_connect("CONNECT host.com443 HTTP/1.0")
assert not http.parse_init_connect("CONNECT host.com:443 foo/1.0")
+ assert not http.parse_init_connect("CONNECT host.com:foo HTTP/1.0")
def test_prase_init_proxy():