mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-01 15:55:28 +00:00
Add option to control stripping newlines from edited bodies (#4125)
This commit is contained in:
parent
5cb403002f
commit
c48a2fcc4f
@ -6,6 +6,7 @@ Unreleased: mitmproxy next
|
||||
* Use `@charset` to decode CSS files if available (@prinzhorn)
|
||||
* Fix links to anticache docs in mitmweb and use HTTPS for links to documentation (@rugk)
|
||||
* Updated typing for WebsocketMessage.content (@prinzhorn)
|
||||
* Add option `console_strip_trailing_newlines`, and no longer strip trailing newlines by default (@capt8bit)
|
||||
* Prevent transparent mode from connecting to itself in the basic cases (@prinzhorn)
|
||||
* Display HTTP trailers in mitmweb (@sanlengjingvv)
|
||||
* Revamp onboarding app (@mhils)
|
||||
|
@ -120,13 +120,16 @@ class ConsoleAddon:
|
||||
"console_mouse", bool, True,
|
||||
"Console mouse interaction."
|
||||
)
|
||||
|
||||
loader.add_option(
|
||||
"console_flowlist_layout",
|
||||
str, "default",
|
||||
"Set the flowlist layout",
|
||||
choices=sorted(console_flowlist_layout)
|
||||
)
|
||||
loader.add_option(
|
||||
"console_strip_trailing_newlines", bool, False,
|
||||
"Strip trailing newlines from edited request/response bodies."
|
||||
)
|
||||
|
||||
@command.command("console.layout.options")
|
||||
def layout_options(self) -> typing.Sequence[str]:
|
||||
@ -449,13 +452,14 @@ class ConsoleAddon:
|
||||
else:
|
||||
message = flow.response
|
||||
c = self.master.spawn_editor(message.get_content(strict=False) or b"")
|
||||
# Fix an issue caused by some editors when editing a
|
||||
# request/response body. Many editors make it hard to save a
|
||||
# file without a terminating newline on the last line. When
|
||||
# editing message bodies, this can cause problems. For now, I
|
||||
# just strip the newlines off the end of the body when we return
|
||||
# from an editor.
|
||||
# Many editors make it hard to save a file without a terminating
|
||||
# newline on the last line. When editing message bodies, this can
|
||||
# cause problems. We strip trailing newlines by default, but this
|
||||
# behavior is configurable.
|
||||
if self.master.options.console_strip_trailing_newlines:
|
||||
message.content = c.rstrip(b"\n")
|
||||
else:
|
||||
message.content = c
|
||||
elif flow_part == "set-cookies":
|
||||
self.master.switch_view("edit_focus_setcookies")
|
||||
elif flow_part == "url":
|
||||
|
Loading…
Reference in New Issue
Block a user