aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorThomas Kriechbaumer <Kriechi@users.noreply.github.com>2019-09-28 11:46:58 +0200
committerGitHub <noreply@github.com>2019-09-28 11:46:58 +0200
commit7d60dde76cbcc115b33c3d763de5995ef5621565 (patch)
tree9ec9510e3b5d77daca7fafeb35a954b75b63bfdb /test
parent76bd3ef82dd6b8e3d00b9b4dfe56c96a3c22dd47 (diff)
parentba054b15f367d59139ec78fe03dc1c7d8fb099b5 (diff)
downloadmitmproxy-7d60dde76cbcc115b33c3d763de5995ef5621565.tar.gz
mitmproxy-7d60dde76cbcc115b33c3d763de5995ef5621565.tar.bz2
mitmproxy-7d60dde76cbcc115b33c3d763de5995ef5621565.zip
Merge pull request #3464 from rjt-gupta/url-fix
Non ascii characters in url
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/net/http/test_url.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/mitmproxy/net/http/test_url.py b/test/mitmproxy/net/http/test_url.py
index ecf8e896..48277859 100644
--- a/test/mitmproxy/net/http/test_url.py
+++ b/test/mitmproxy/net/http/test_url.py
@@ -49,6 +49,17 @@ def test_parse():
url.parse('http://lo[calhost')
+def test_ascii_check():
+
+ test_url = "https://xyz.tax-edu.net?flag=selectCourse&lc_id=42825&lc_name=茅莽莽猫氓猫氓".encode()
+ scheme, host, port, full_path = url.parse(test_url)
+ assert scheme == b'https'
+ assert host == b'xyz.tax-edu.net'
+ assert port == 443
+ assert full_path == b'/?flag%3DselectCourse%26lc_id%3D42825%26lc_name%3D%E8%8C%85%E8%8E%BD%E8%8E' \
+ b'%BD%E7%8C%AB%E6%B0%93%E7%8C%AB%E6%B0%93'
+
+
@pytest.mark.skipif(sys.version_info < (3, 6), reason='requires Python 3.6 or higher')
def test_parse_port_range():
# Port out of range
@@ -61,6 +72,7 @@ def test_unparse():
assert url.unparse("http", "foo.com", 80, "/bar") == "http://foo.com/bar"
assert url.unparse("https", "foo.com", 80, "") == "https://foo.com:80"
assert url.unparse("https", "foo.com", 443, "") == "https://foo.com"
+ assert url.unparse("https", "foo.com", 443, "*") == "https://foo.com"
# We ignore the byte 126: '~' because of an incompatibility in Python 3.6 and 3.7
@@ -131,3 +143,7 @@ def test_unquote():
assert url.unquote("foo") == "foo"
assert url.unquote("foo%20bar") == "foo bar"
assert url.unquote(surrogates_quoted) == surrogates
+
+
+def test_hostport():
+ assert url.hostport(b"https", b"foo.com", 8080) == b"foo.com:8080"