diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2011-09-07 09:53:53 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2011-09-07 09:53:53 +1200 |
commit | 362fdf9bae85250634c59d07b60158ff642a12c0 (patch) | |
tree | 1385367050b6bae4af0747cbb3c528f76d762a07 | |
parent | 7629a43d82bb6090ebf9101383603f81f6f9940a (diff) | |
parent | e5bded7deecb396bef33ebc0a5e345e4d8cf7928 (diff) | |
download | mitmproxy-362fdf9bae85250634c59d07b60158ff642a12c0.tar.gz mitmproxy-362fdf9bae85250634c59d07b60158ff642a12c0.tar.bz2 mitmproxy-362fdf9bae85250634c59d07b60158ff642a12c0.zip |
Merge branch 'master' of ssh.github.com:cortesi/mitmproxy
-rw-r--r-- | libmproxy/controller.py | 2 | ||||
-rw-r--r-- | libmproxy/proxy.py | 6 | ||||
-rw-r--r-- | libmproxy/utils.py | 7 | ||||
-rw-r--r-- | test/test_utils.py | 3 |
4 files changed, 14 insertions, 4 deletions
diff --git a/libmproxy/controller.py b/libmproxy/controller.py index 756e51e6..67ce2460 100644 --- a/libmproxy/controller.py +++ b/libmproxy/controller.py @@ -80,6 +80,8 @@ class Master: return changed def run(self): + global should_exit + should_exit = False if self.server: slave = Slave(self.masterq, self.server) slave.start() diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 5a2a4f43..f0640f23 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -104,7 +104,6 @@ def parse_request_line(request): return method, scheme, host, port, path, minor - class FileLike: def __init__(self, o): self.o = o @@ -197,7 +196,10 @@ class ServerConnection: if not len(parts) == 3: raise ProxyError(502, "Invalid server response: %s."%line) proto, code, msg = parts - code = int(code) + try: + code = int(code) + except ValueError: + raise ProxyError(502, "Invalid server response: %s."%line) headers = flow.Headers() headers.read(self.rfile) if code >= 100 and code <= 199: diff --git a/libmproxy/utils.py b/libmproxy/utils.py index ecf77263..37b751dc 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -393,8 +393,11 @@ def parse_url(url): if not scheme: return None if ':' in netloc: - host, port = string.split(netloc, ':') - port = int(port) + host, port = string.rsplit(netloc, ':', maxsplit=1) + try: + port = int(port) + except ValueError: + return None else: host = netloc if scheme == "https": diff --git a/test/test_utils.py b/test/test_utils.py index 8b16e057..12917444 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -216,6 +216,9 @@ class u_parse_url(libpry.AutoTree): s, h, po, pa = utils.parse_url("https://foo") assert po == 443 + assert not utils.parse_url("https://foo:bar") + assert not utils.parse_url("https://foo:") + tests = [ uformat_timestamp(), uisBin(), |