diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-07-06 17:35:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-06 17:35:34 -0700 |
commit | 55fae7cea90ee69338ef410e1db4a48b8b604619 (patch) | |
tree | ef40d914d9bc3b994fff218427c7a78747c694cd | |
parent | 444f0a4c397e3d664ce80f65d176d871b8e1194e (diff) | |
parent | 8b564bc934b8b51734c41192ecb0135c264087cc (diff) | |
download | mitmproxy-55fae7cea90ee69338ef410e1db4a48b8b604619.tar.gz mitmproxy-55fae7cea90ee69338ef410e1db4a48b8b604619.tar.bz2 mitmproxy-55fae7cea90ee69338ef410e1db4a48b8b604619.zip |
Merge pull request #1319 from mitmproxy/fix-py27-encoding-issues
Fix pathod log encoding
-rw-r--r-- | netlib/strutils.py | 4 | ||||
-rw-r--r-- | pathod/log.py | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/netlib/strutils.py b/netlib/strutils.py index 7ad15c96..cda70651 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -149,8 +149,8 @@ def hexdump(s): part = s[i:i + 16] x = " ".join("{:0=2x}".format(i) for i in six.iterbytes(part)) x = x.ljust(47) # 16*2 + 15 - part_repr = escape_control_characters( + part_repr = native(escape_control_characters( part.decode("ascii", "replace").replace(u"\ufffd", u"."), False - ) + )) yield (offset, x, part_repr) diff --git a/pathod/log.py b/pathod/log.py index d39496e0..47837101 100644 --- a/pathod/log.py +++ b/pathod/log.py @@ -62,9 +62,15 @@ class LogCtx(object): for line in strutils.hexdump(data): self("\t%s %s %s" % line) else: - data = data.decode("ascii", "replace").replace(u"\ufffd", u".") - for i in strutils.escape_control_characters(data).split(u"\n"): - self(u"\t%s" % i) + data = strutils.native( + strutils.escape_control_characters( + data + .decode("ascii", "replace") + .replace(u"\ufffd", u".") + ) + ) + for i in data.split("\n"): + self("\t%s" % i) def __call__(self, line): self.lines.append(line) |