diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-05-12 11:03:57 -0600 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-05-12 11:03:57 -0600 |
commit | f1c922c652ec90f63cafed7f6b68d17f5229b58d (patch) | |
tree | 1091dc76bb1201dd334612a1d5bfa33f2918ad27 /mitmproxy | |
parent | 518cc78454f9656be37e3153e2b508e56aa7ebf7 (diff) | |
download | mitmproxy-f1c922c652ec90f63cafed7f6b68d17f5229b58d.tar.gz mitmproxy-f1c922c652ec90f63cafed7f6b68d17f5229b58d.tar.bz2 mitmproxy-f1c922c652ec90f63cafed7f6b68d17f5229b58d.zip |
Sanitize Print (#1135)
* sanitize strings with shell control characters
* netlib: add utilities to safe-print bytes
* escaped str: add TODO for multi-byte chars
Diffstat (limited to 'mitmproxy')
-rw-r--r-- | mitmproxy/dump.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index 0e0ccc62..aae397cd 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -5,7 +5,7 @@ import click import itertools from netlib import tcp -import netlib.utils +from netlib.utils import bytes_to_escaped_str, pretty_size from . import flow, filt, contentviews from .exceptions import ContentViewException, FlowReadException, ScriptException @@ -175,8 +175,8 @@ class DumpMaster(flow.FlowMaster): if self.o.flow_detail >= 2: headers = "\r\n".join( "{}: {}".format( - click.style(k, fg="blue", bold=True), - click.style(v, fg="blue")) + click.style(bytes_to_escaped_str(k), fg="blue", bold=True), + click.style(bytes_to_escaped_str(v), fg="blue")) for k, v in message.headers.fields ) self.echo(headers, indent=4) @@ -238,7 +238,7 @@ class DumpMaster(flow.FlowMaster): stickycookie = "" if flow.client_conn: - client = click.style(flow.client_conn.address.host, bold=True) + client = click.style(bytes_to_escaped_str(flow.client_conn.address.host), bold=True) else: client = click.style("[replay]", fg="yellow", bold=True) @@ -247,12 +247,12 @@ class DumpMaster(flow.FlowMaster): GET="green", DELETE="red" ).get(method.upper(), "magenta") - method = click.style(method, fg=method_color, bold=True) + method = click.style(bytes_to_escaped_str(method), fg=method_color, bold=True) if self.showhost: url = flow.request.pretty_url else: url = flow.request.url - url = click.style(url, bold=True) + url = click.style(bytes_to_escaped_str(url), bold=True) httpversion = "" if flow.request.http_version not in ("HTTP/1.1", "HTTP/1.0"): @@ -282,12 +282,12 @@ class DumpMaster(flow.FlowMaster): elif 400 <= code < 600: code_color = "red" code = click.style(str(code), fg=code_color, bold=True, blink=(code == 418)) - reason = click.style(flow.response.reason, fg=code_color, bold=True) + reason = click.style(bytes_to_escaped_str(flow.response.reason), fg=code_color, bold=True) if flow.response.content is None: size = "(content missing)" else: - size = netlib.utils.pretty_size(len(flow.response.content)) + size = pretty_size(len(flow.response.content)) size = click.style(size, bold=True) arrows = click.style("<<", bold=True) @@ -349,4 +349,4 @@ class DumpMaster(flow.FlowMaster): if self.o.rfile and not self.o.keepserving: self.unload_scripts() # make sure to trigger script unload events. return - super(DumpMaster, self).run()
\ No newline at end of file + super(DumpMaster, self).run() |