You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exporting a curl command with escaped characters results in a different request #7517
When copying a command to curl that contains newline or other characters, the resulting curl request is different to the original.
Steps to reproduce the behavior:
Make a request that includes escaped characters: curl -H 'content-type: application/octet-stream' -d $'foo\nbar' -x localhost:8080 http://example.com
In mitmproxy, you will see that the request body is
foo
bar
Copy this request as curl from mitmproxy (export -> curl)
You get:
You see that the request body is not the same as the original:
foo\x0abar
The escape characters that are added here are not being unquoted when being sent by curl, and so are just "characters".
I think the solution would be to let bash replace those characters using $ in front of the string: ... -d $'foo\x0abar or using --data-binary with a temporary file.
Activity
mhils commentedon Jan 27, 2025
Thanks for the report. Happy to merge a fix. My preferred solution would be to use something like
-d "$(printf 'foo\nbar')"In contrast to
$''-style strings, that works with a bunch of non-bash shells as well (e.g. fish shell).proteusvacuum commentedon Jan 27, 2025
Thanks @mhils , I'll put together a PR.
Unescape escaped characters in curl and httpie args
Unescape escaped characters in curl and httpie args
Unescape escaped characters in curl and httpie args (#7520)