Removed escaping string to get real raw view (#5894)

* Removed escaping string to get real raw view

* [autofix.ci] apply automated fixes

* Updated changelog

* extend tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
This commit is contained in:
stephenspol 2023-01-29 05:56:39 -05:00 committed by GitHub
parent 0c4549f4cc
commit 849a3c33cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -9,6 +9,8 @@
([#5725](https://github.com/mitmproxy/mitmproxy/pull/5725), @mhils)
* Add `replay.server.add` command for adding flows to server replay buffer
([#5851](https://github.com/mitmproxy/mitmproxy/pull/5851), @italankin)
* Removed string escaping in raw view.
([#5470](https://github.com/mitmproxy/mitmproxy/issues/5470), @stephenspol)
### Breaking Changes

View File

@ -1,12 +1,11 @@
from . import base
from mitmproxy.utils import strutils
class ViewRaw(base.View):
name = "Raw"
def __call__(self, data, **metadata):
return "Raw", base.format_text(strutils.bytes_to_escaped_str(data, True))
return "Raw", base.format_text(data)
def render_priority(self, data: bytes, **metadata) -> float:
return 0.1 * float(bool(data))

View File

@ -5,6 +5,16 @@ from mitmproxy.contentviews import raw
def test_view_raw():
v = full_eval(raw.ViewRaw())
assert v(b"foo")
# unicode
assert v("🫠".encode()) == (
"Raw",
[[("text", "🫠".encode())]],
)
# invalid utf8
assert v(b"\xFF") == (
"Raw",
[[("text", b"\xFF")]],
)
def test_render_priority():