Fix #8050: add -- to printf in curl export for data starting with dashes by cobyfrombrooklyn-bot · Pull Request #8100 · mitmproxy/mitmproxy
When request content contains control characters and starts with dashes (e.g. multipart boundary markers like ---boundary\r\ndata), the exported curl command uses printf without --, causing bash to interpret the leading dashes as printf options:
bash: printf: --: invalid option
Fix
Added -- after printf in request_content_for_console() to signal end of options. This ensures the argument is always treated as the format string regardless of its content.
One-character fix in mitmproxy/addons/export.py.
Test
Added test_expand_escaped_dash_prefix that verifies curl export with ---boundary\r\ndata content produces printf -- '---boundary\x0d\x0adata' (with --). Updated existing test_expand_escaped expectation to match. Full export test suite passes (42 tests).
Tested locally on macOS ARM (Apple Silicon).
Fixes #8050