diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2018-05-14 10:39:00 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2018-05-14 10:41:46 +0200 |
commit | 9979be648750b6983b233ec3a8c3c644d8c332a1 (patch) | |
tree | 3d1e13f452dc50e79895bef861ff3672a9a4c530 /test | |
parent | 64785239135c12290fae549cfe756ed7cede67e0 (diff) | |
download | mitmproxy-9979be648750b6983b233ec3a8c3c644d8c332a1.tar.gz mitmproxy-9979be648750b6983b233ec3a8c3c644d8c332a1.tar.bz2 mitmproxy-9979be648750b6983b233ec3a8c3c644d8c332a1.zip |
fix py36/37 escaping issues
closes #3122
https://bugs.python.org/issue16285
https://bugs.python.org/issue12910
https://github.com/python/cpython/commit/21024f06622c4c55b666adb130797a4ee205d005
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/net/http/test_url.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/mitmproxy/net/http/test_url.py b/test/mitmproxy/net/http/test_url.py index c9f61faf..ecf8e896 100644 --- a/test/mitmproxy/net/http/test_url.py +++ b/test/mitmproxy/net/http/test_url.py @@ -63,17 +63,21 @@ def test_unparse(): assert url.unparse("https", "foo.com", 443, "") == "https://foo.com" -surrogates = bytes(range(256)).decode("utf8", "surrogateescape") +# We ignore the byte 126: '~' because of an incompatibility in Python 3.6 and 3.7 +# In 3.6 it is escaped as %7E +# In 3.7 it stays as ASCII character '~' +# https://bugs.python.org/issue16285 +surrogates = (bytes(range(0, 126)) + bytes(range(127, 256))).decode("utf8", "surrogateescape") surrogates_quoted = ( '%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F' '%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F' '%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-./' - '0123456789%3A%3B%3C%3D%3E%3F' - '%40ABCDEFGHIJKLMNO' - 'PQRSTUVWXYZ%5B%5C%5D%5E_' - '%60abcdefghijklmno' - 'pqrstuvwxyz%7B%7C%7D%7E%7F' + '0123456789%3A%3B%3C%3D%3E%3F%40' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + '%5B%5C%5D%5E_%60' + 'abcdefghijklmnopqrstuvwxyz' + '%7B%7C%7D%7F' # 7E or ~ is excluded! '%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F' '%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F' '%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF' |