mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 16:17:49 +00:00
Make previews safer by stripping pauses.
This commit is contained in:
parent
e9de11f0e3
commit
6c565e778f
@ -90,6 +90,7 @@ def preview():
|
|||||||
return render("preview.html", **args)
|
return render("preview.html", **args)
|
||||||
|
|
||||||
s = cStringIO.StringIO()
|
s = cStringIO.StringIO()
|
||||||
|
r.preview_safe()
|
||||||
r.serve(s, check=app.config["pathod"].check_size)
|
r.serve(s, check=app.config["pathod"].check_size)
|
||||||
args["output"] = utils.escape_unprintables(s.getvalue())
|
args["output"] = utils.escape_unprintables(s.getvalue())
|
||||||
return render("preview.html", **args)
|
return render("preview.html", **args)
|
||||||
|
@ -527,6 +527,12 @@ class Message:
|
|||||||
l += len(self.body)
|
l += len(self.body)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
def preview_safe(self):
|
||||||
|
"""
|
||||||
|
Modify this message to be safe for previews.
|
||||||
|
"""
|
||||||
|
self.actions = [i for i in self.actions if i[1] != "pause"]
|
||||||
|
|
||||||
def effective_length(self, actions):
|
def effective_length(self, actions):
|
||||||
"""
|
"""
|
||||||
Calculate the length of the base message with all applied actions.
|
Calculate the length of the base message with all applied actions.
|
||||||
|
@ -493,6 +493,12 @@ class TestResponse:
|
|||||||
r.actions = actions
|
r.actions = actions
|
||||||
testlen(r, actions)
|
testlen(r, actions)
|
||||||
|
|
||||||
|
def test_render(self):
|
||||||
|
r = rparse.parse_response({}, "400:p0,100:dr")
|
||||||
|
assert r.actions[0][1] == "pause"
|
||||||
|
r.preview_safe()
|
||||||
|
assert not r.actions[0][1] == "pause"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_read_file():
|
def test_read_file():
|
||||||
|
Loading…
Reference in New Issue
Block a user