aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-01-06 00:58:29 +0100
committerMaximilian Hils <git@maximilianhils.com>2017-01-07 23:08:50 +0100
commitb1ec7e78cdb3bb0432667d7a029cfe00f07a3b11 (patch)
tree534f27bcad822a6e5ad5951875a4a1a2aba8bb93
parentc21ee90debe13154f4d34aed1f088796a2d0c02c (diff)
downloadmitmproxy-b1ec7e78cdb3bb0432667d7a029cfe00f07a3b11.tar.gz
mitmproxy-b1ec7e78cdb3bb0432667d7a029cfe00f07a3b11.tar.bz2
mitmproxy-b1ec7e78cdb3bb0432667d7a029cfe00f07a3b11.zip
Revert "add strutils.replace_surrogates"
This reverts commit 15ae88db08dbf2725c8c9f945f2006c4b2a10d46.
-rw-r--r--mitmproxy/utils/strutils.py11
-rw-r--r--test/mitmproxy/utils/test_strutils.py5
2 files changed, 0 insertions, 16 deletions
diff --git a/mitmproxy/utils/strutils.py b/mitmproxy/utils/strutils.py
index 9c5e6bc8..29465615 100644
--- a/mitmproxy/utils/strutils.py
+++ b/mitmproxy/utils/strutils.py
@@ -25,17 +25,6 @@ def always_str(str_or_bytes: Optional[AnyStr], *decode_args) -> Optional[str]:
raise TypeError("Expected str or bytes, but got {}.".format(type(str_or_bytes).__name__))
-def replace_surrogates(text: str, errors='replace') -> str:
- """Convert surrogates to replacement characters (e.g., "\udc80" becomes "�")
- by applying a different error handler.
-
- Uses the "replace" error handler by default, but any input
- error handler may be specified.
-
- For an introduction to surrogateescape, see https://www.python.org/dev/peps/pep-0383/.
- """
- return text.encode('utf-8', 'surrogateescape').decode('utf-8', errors)
-
# Translate control characters to "safe" characters. This implementation initially
# replaced them with the matching control pictures (http://unicode.org/charts/PDF/U2400.pdf),
# but that turned out to render badly with monospace fonts. We are back to "." therefore.
diff --git a/test/mitmproxy/utils/test_strutils.py b/test/mitmproxy/utils/test_strutils.py
index 1fb4949f..1372d31f 100644
--- a/test/mitmproxy/utils/test_strutils.py
+++ b/test/mitmproxy/utils/test_strutils.py
@@ -19,11 +19,6 @@ def test_always_str():
assert strutils.always_str(None) is None
-def test_replace_surrogates():
- assert strutils.replace_surrogates("foo") == "foo"
- assert strutils.replace_surrogates("bar \udc80 baz") == "bar � baz"
-
-
def test_escape_control_characters():
assert strutils.escape_control_characters(u"one") == u"one"
assert strutils.escape_control_characters(u"\00ne") == u".ne"