diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-07-01 17:17:16 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-07-01 17:17:16 -0700 |
commit | fa7246279817b7c01448fd4059c8d2be34e84f8b (patch) | |
tree | c223573d8b3fd24c2e5dbe037df3f0bf35265884 /netlib/strutils.py | |
parent | 536c7acd13426d42dc863ae8b50e6c3a4cb2e858 (diff) | |
download | mitmproxy-fa7246279817b7c01448fd4059c8d2be34e84f8b.tar.gz mitmproxy-fa7246279817b7c01448fd4059c8d2be34e84f8b.tar.bz2 mitmproxy-fa7246279817b7c01448fd4059c8d2be34e84f8b.zip |
fix tcp message handling
Diffstat (limited to 'netlib/strutils.py')
-rw-r--r-- | netlib/strutils.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/netlib/strutils.py b/netlib/strutils.py index ca6eaa42..414b2e57 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -29,6 +29,7 @@ def native(s, *encoding_opts): def clean_bin(s, keep_spacing=True): + # type: (Union[bytes, six.text_type], bool) -> six.text_type """ Cleans binary data to make it safe to display. @@ -49,8 +50,8 @@ def clean_bin(s, keep_spacing=True): keep = (9, 10, 13) # \t, \n, \r, else: keep = () - return b"".join( - six.int2byte(ch) if (31 < ch < 127 or ch in keep) else b"." + return "".join( + chr(ch) if (31 < ch < 127 or ch in keep) else "." for ch in six.iterbytes(s) ) @@ -133,6 +134,6 @@ def hexdump(s): for i in range(0, len(s), 16): offset = "{:0=10x}".format(i).encode() part = s[i:i + 16] - x = b" ".join("{:0=2x}".format(i).encode() for i in six.iterbytes(part)) + x = " ".join("{:0=2x}".format(i) for i in six.iterbytes(part)) x = x.ljust(47) # 16*2 + 15 yield (offset, x, clean_bin(part, False)) |