aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_contentview.py8
-rw-r--r--test/netlib/test_encoding.py12
-rw-r--r--test/netlib/test_strutils.py5
3 files changed, 21 insertions, 4 deletions
diff --git a/test/mitmproxy/test_contentview.py b/test/mitmproxy/test_contentview.py
index aad53b37..66cad47b 100644
--- a/test/mitmproxy/test_contentview.py
+++ b/test/mitmproxy/test_contentview.py
@@ -78,6 +78,7 @@ class TestContentView:
v = cv.ViewHTMLOutline()
s = b"<html><br><br></br><p>one</p></html>"
assert v(s)
+ assert v(b'\xfe')
def test_view_json(self):
cv.VIEW_CUTOFF = 100
@@ -106,9 +107,10 @@ class TestContentView:
def test_view_javascript(self):
v = cv.ViewJavaScript()
- assert v("[1, 2, 3]")
- assert v("[1, 2, 3")
- assert v("function(a){[1, 2, 3]}")
+ assert v(b"[1, 2, 3]")
+ assert v(b"[1, 2, 3")
+ assert v(b"function(a){[1, 2, 3]}")
+ assert v(b"\xfe") # invalid utf-8
def test_view_css(self):
v = cv.ViewCSS()
diff --git a/test/netlib/test_encoding.py b/test/netlib/test_encoding.py
index a5e81379..08e69ec5 100644
--- a/test/netlib/test_encoding.py
+++ b/test/netlib/test_encoding.py
@@ -21,6 +21,18 @@ def test_gzip():
encoding.decode(b"bogus", "gzip")
+def test_brotli():
+ assert b"string" == encoding.decode(
+ encoding.encode(
+ b"string",
+ "br"
+ ),
+ "br"
+ )
+ with tutils.raises(ValueError):
+ encoding.decode(b"bogus", "br")
+
+
def test_deflate():
assert b"string" == encoding.decode(
encoding.encode(
diff --git a/test/netlib/test_strutils.py b/test/netlib/test_strutils.py
index 7c3eacc6..52299e59 100644
--- a/test/netlib/test_strutils.py
+++ b/test/netlib/test_strutils.py
@@ -48,9 +48,12 @@ def test_bytes_to_escaped_str():
assert strutils.bytes_to_escaped_str(b"\b") == r"\x08"
assert strutils.bytes_to_escaped_str(br"&!?=\)") == r"&!?=\\)"
assert strutils.bytes_to_escaped_str(b'\xc3\xbc') == r"\xc3\xbc"
- assert strutils.bytes_to_escaped_str(b"'") == r"\'"
+ assert strutils.bytes_to_escaped_str(b"'") == r"'"
assert strutils.bytes_to_escaped_str(b'"') == r'"'
+ assert strutils.bytes_to_escaped_str(b"'", escape_single_quotes=True) == r"\'"
+ assert strutils.bytes_to_escaped_str(b'"', escape_single_quotes=True) == r'"'
+
assert strutils.bytes_to_escaped_str(b"\r\n\t") == "\\r\\n\\t"
assert strutils.bytes_to_escaped_str(b"\r\n\t", True) == "\r\n\t"