diff options
author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2018-01-08 15:45:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-08 15:45:28 +0100 |
commit | 67300fab3119f055a6cbb43b7cbc9d33e849d165 (patch) | |
tree | 03cbac2b88606b348717a87a2cfc703672cac8c4 | |
parent | 821d76df02f70ccca5623cbc65d02b80e3998704 (diff) | |
parent | a6f6f8cd3226de3c89ec9d6cdeab972c88b94a18 (diff) | |
download | mitmproxy-67300fab3119f055a6cbb43b7cbc9d33e849d165.tar.gz mitmproxy-67300fab3119f055a6cbb43b7cbc9d33e849d165.tar.bz2 mitmproxy-67300fab3119f055a6cbb43b7cbc9d33e849d165.zip |
Merge pull request #2773 from MatthewShao/fix#2760
Fix #2760
-rw-r--r-- | mitmproxy/addons/view.py | 5 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_view.py | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py index 5fbefdb0..c3fb4b88 100644 --- a/mitmproxy/addons/view.py +++ b/mitmproxy/addons/view.py @@ -441,7 +441,10 @@ class View(collections.Sequence): @command.command("view.create") def create(self, method: str, url: str) -> None: - req = http.HTTPRequest.make(method.upper(), url) + try: + req = http.HTTPRequest.make(method.upper(), url) + except ValueError as e: + raise exceptions.CommandError("Invalid URL: %s" % e) c = connections.ClientConnection.make_dummy(("", 0)) s = connections.ServerConnection.make_dummy((req.host, req.port)) f = http.HTTPFlow(c, s) diff --git a/test/mitmproxy/addons/test_view.py b/test/mitmproxy/addons/test_view.py index 6e4af367..a95d059d 100644 --- a/test/mitmproxy/addons/test_view.py +++ b/test/mitmproxy/addons/test_view.py @@ -147,6 +147,10 @@ def test_create(): assert v[0].request.url == "http://foo.com/" v.create("get", "http://foo.com") assert len(v) == 2 + with pytest.raises(exceptions.CommandError, match="Invalid URL"): + v.create("get", "http://foo.com\\") + with pytest.raises(exceptions.CommandError, match="Invalid URL"): + v.create("get", "http://") def test_orders(): |