Skip to content

Instantly share code, notes, and snippets.

@magks
Created October 2, 2023 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magks/f0a566caba74fd08036a94f90b6f67a1 to your computer and use it in GitHub Desktop.
Save magks/f0a566caba74fd08036a94f90b6f67a1 to your computer and use it in GitHub Desktop.
curl unescape percent encoded characters before writing file
Hi Daniel, I saw this comment thread and added the feature to decode the filename before writing similar to wget's behavior. Thus option -W seemed fitting and was available.
so it can be used exactly like -O and -J:
`curl -W https://www.example.com/new%20pricing.htm`
> 'new pricing.htm'
curl -WJ http://test.greenbytes.de/tech/tc2231/attwithfnrawpctenca.asis
> foo-A.html
curl --remote-name-decode-all https://www.example.com/new%20pricing.htm http://test.greenbytes.de/tech/tc2231/attwithfnrawpctenca.asis
> 'new pricing.htm'
> attwithfnrawpctenca.asis
curl --remote-name-decode-all -J https://www.example.com/new%20pricing.htm http://test.greenbytes.de/tech/tc2231/attwithfnrawpctenca.asis
> 'new pricing.htm'
> foo-A.html
I have the changes in feature/remote-name-decoded branch here:
https://github.com/magks/curl/tree/feature/remote-name-decoded
I tried to keep changes as minimal and simple as possible and made use of the lib/escape.h `Curl_urldecode` function, however because of this, the linker can only find the symbol when I pass `--disable-symbol-hiding` to ./configure.
I wanted to discuss with you what approach you'd recommend taking to include the function from escape.h in tool_operhlp.c and tool_cb_wrt.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment