correct a parameter (#8172)

Co-authored-by: Maximilian Hils <git@maximilianhils.com>
This commit is contained in:
nameearly 2026-04-12 22:17:13 +08:00 committed by GitHub
parent d1e06b6870
commit 6d1f71ee2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View file

@ -7,6 +7,8 @@
## Unreleased: mitmproxy next
- Fix `view.settings.setval.toggle` command to correctly use the provided key parameter instead of hardcoded "key" string.
([#8167](https://github.com/mitmproxy/mitmproxy/pull/8167), @nameearly)
- Fix 400 Bad Request for HTTP requests with uppercase scheme (e.g. `HTTP://`).
([#8174](https://github.com/mitmproxy/mitmproxy/pull/8174), @emanuele-em)
- Fix console command panel losing focus due to incoming traffic (e.g. websocket messages).

View file

@ -394,7 +394,7 @@ class View(collections.abc.Sequence):
"""
updated = []
for f in flows:
current = self.settings[f].get("key", "false")
current = self.settings[f].get(key, "false")
self.settings[f][key] = "false" if current == "true" else "true"
updated.append(f)
ctx.master.addons.trigger(hooks.UpdateHook(updated))

View file

@ -393,6 +393,13 @@ def test_setgetval():
v.setvalue_toggle([f], "key")
assert v.getvalue(f, "key", "default") == "false"
# Test with a different key name to verify the fix for hardcoded "key" bug
v.setvalue([f], "custom_setting", "true")
v.setvalue_toggle([f], "custom_setting")
assert v.getvalue(f, "custom_setting", "default") == "false"
v.setvalue_toggle([f], "custom_setting")
assert v.getvalue(f, "custom_setting", "default") == "true"
def test_order():
v = view.View()