mitmproxy / mitmproxy/mitmproxy

Crashes when copying response to clipboard

Open
#4,209 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/triage
Dominant language
Python
Stars
45.1k
Forks
4.7k
Avg merge
21h 12m
Merged PRs (30d)
16

Description

Problem Description

I'm trying to copy a response to the clipboard, it crashes, and it asks me to file a bug here.

Steps to reproduce the behavior:
  1. Go to response (8.5kb multipart/mixed response)
  2. Type :, then export.clip raw_response @focus, then enter
  3. Following is displayed:
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/master.py", line 86, in run_loop
    loop()
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/main_loop.py", line 287, in run
    self._run()
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/main_loop.py", line 1494, in run
    reraise(*exc_info)
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/compat.py", line 58, in reraise
    raise value
  File "/nix/store/np0b7p04kbhl244yv65d2sc37kk7wcqf-python3-3.8.5/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/raw_display.py", line 416, in <lambda>
    wrapper = lambda: self.parse_input(
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/raw_display.py", line 515, in parse_input
    callback(processed, processed_codes)
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/main_loop.py", line 412, in _update
    self.process_input(keys)
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/tools/console/window.py", line 310, in keypress
    k = super().keypress(size, k)
  File "/nix/store/cnidikkp18zrcrzh55ags3j18c0dw07y-python3.8-urwid-2.1.1/lib/python3.8/site-packages/urwid/container.py", line 1123, in keypress
    return self.footer.keypress((maxcol,),key)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/tools/console/statusbar.py", line 201, in keypress
    return self.ab.keypress(*args, **kwargs)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/tools/console/statusbar.py", line 149, in keypress
    self.prompt_execute(text)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/tools/console/statusbar.py", line 169, in prompt_execute
    msg = p(txt)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/tools/console/statusbar.py", line 115, in execute_command
    execute(txt)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/tools/console/commandexecutor.py", line 18, in __call__
    ret = self.master.commands.execute(cmd)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/command.py", line 266, in execute
    return self.call_strings(command_name, args)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/command.py", line 252, in call_strings
    return self.commands[command_name].call(args)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/command.py", line 122, in call
    ret = self.func(*bound_args.args, **bound_args.kwargs)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/command.py", line 296, in wrapper
    return function(*args, **kwargs)
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/addons/export.py", line 149, in clip
    v = strutils.always_str(func(flow))
  File "/nix/store/bavhjp7n9rkjzvzsavcw2zzyi9kh6xwf-python3.8-mitmproxy-5.2/lib/python3.8/site-packages/mitmproxy/utils/strutils.py", line 26, in always_str
    return str_or_bytes.decode(*decode_args)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 963-964: invalid continuation byte

mitmproxy has crashed!
Please lodge a bug report at:
	https://github.com/mitmproxy/mitmproxy
System Information

nix-shell (Nix) 2.3.7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with mitmproxy/addons/export.py at clip and follow the strutils.always_str call shown in the traceback. Reproduce the command against an 8.5 KB multipart/mixed response containing invalid UTF-8 bytes; done means exporting the raw response no longer crashes the console.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.