diff options
author | Aldo Cortesi <aldo@corte.si> | 2018-05-12 14:41:23 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-12 14:41:23 +1200 |
commit | 7fde02ac90542d932f1d1822dbad6fab761663bd (patch) | |
tree | 568d17d77eacb3ddb2586769ae325eb911c359b4 | |
parent | 2db0245233c272ad9edd0a7710396c38e7c3097d (diff) | |
parent | 58ff51da10eff7090ff2a63436c558b1eb5150c3 (diff) | |
download | mitmproxy-7fde02ac90542d932f1d1822dbad6fab761663bd.tar.gz mitmproxy-7fde02ac90542d932f1d1822dbad6fab761663bd.tar.bz2 mitmproxy-7fde02ac90542d932f1d1822dbad6fab761663bd.zip |
Merge pull request #3117 from cortesi/morefixes
More misc fixes
-rw-r--r-- | mitmproxy/addons/clientplayback.py | 9 | ||||
-rw-r--r-- | mitmproxy/command.py | 5 | ||||
-rw-r--r-- | mitmproxy/controller.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/test_command.py | 2 |
4 files changed, 10 insertions, 10 deletions
diff --git a/mitmproxy/addons/clientplayback.py b/mitmproxy/addons/clientplayback.py index e9fbadce..99ba1d8d 100644 --- a/mitmproxy/addons/clientplayback.py +++ b/mitmproxy/addons/clientplayback.py @@ -59,9 +59,7 @@ class RequestReplayThread(basethread.BaseThread): # In all modes, we directly connect to the server displayed if self.options.mode.startswith("upstream:"): server_address = server_spec.parse_with_mode(self.options.mode)[1].address - server = connections.ServerConnection( - server_address, (self.options.listen_host, 0) - ) + server = connections.ServerConnection(server_address) server.connect() if r.scheme == "https": connect_request = http.make_connect_request((r.data.host, r.port)) @@ -85,10 +83,7 @@ class RequestReplayThread(basethread.BaseThread): r.first_line_format = "absolute" else: server_address = (r.host, r.port) - server = connections.ServerConnection( - server_address, - (self.options.listen_host, 0) - ) + server = connections.ServerConnection(server_address) server.connect() if r.scheme == "https": server.establish_tls( diff --git a/mitmproxy/command.py b/mitmproxy/command.py index c94e8abb..27f0921d 100644 --- a/mitmproxy/command.py +++ b/mitmproxy/command.py @@ -236,7 +236,10 @@ class CommandManager(mitmproxy.types._CommandBase): """ Execute a command string. May raise CommandError. """ - parts = list(lexer(cmdstr)) + try: + parts = list(lexer(cmdstr)) + except ValueError as e: + raise exceptions.CommandError("Command error: %s" % e) if not len(parts) >= 1: raise exceptions.CommandError("Invalid command: %s" % cmdstr) return self.call_strings(parts[0], parts[1:]) diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py index 6e219066..39d3b74a 100644 --- a/mitmproxy/controller.py +++ b/mitmproxy/controller.py @@ -96,8 +96,8 @@ class Reply: def commit(self): """ Ultimately, messages are committed. This is done either automatically by - if the message is not taken or manually by the entity which called - .take(). + the handler if the message is not taken or manually by the entity which + called .take(). """ if self.state != "taken": raise exceptions.ControlException( diff --git a/test/mitmproxy/test_command.py b/test/mitmproxy/test_command.py index 7c0dc06d..029dbafd 100644 --- a/test/mitmproxy/test_command.py +++ b/test/mitmproxy/test_command.py @@ -281,6 +281,8 @@ def test_simple(): c.execute("one.two too many args") with pytest.raises(exceptions.CommandError, match="Unknown"): c.call("nonexistent") + with pytest.raises(exceptions.CommandError, match="No escaped"): + c.execute("\\") c.add("empty", a.empty) c.execute("empty") |