httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.56k stars 3.67k forks source link

Bad filename when having non ASCII characters #1401

Open jackdeguest opened 2 years ago

jackdeguest commented 2 years ago

Checklist


Minimal reproduction code and steps

  1. save a dummy image as 天狗.png
  2. issue a multipart/form-data, such as: https --offline --multipart https://example.org name='John Doe' file_field@/home/john/天狗.png > /tmp/httpie_result.txt

Current result

The Content-Disposition header generated will be something like: Content-Disposition: form-data; name="file_field"; filename="天狗.png"

Expected result

The Content-Disposition header should conform to rfc2231. So this should rather be: Content-Disposition: form-data; name="file_field"; filename*=UTF-8''%E5%A4%A9%E7%8B%97.png

You can generate the proper encoded filename in accordance with rfc2231 using the perl command line perl -MEncode -MURI::Escape::XS -lE 'say URI::Escape::XS::uri_escape( Encode::decode_utf8("天狗.png") )'


Debug output

Please re-run the command with --debug, then copy the entire command & output and paste both below:

$ http --debug <COMPLETE ARGUMENT LIST THAT TRIGGERS THE ERROR>
<COMPLETE OUTPUT>

Additional information, screenshots, or code examples

isidentical commented 2 years ago

Thanks @jackdeguest, we will be looking for this one!

arabcoders commented 1 year ago

This is problem for downloaded content as well

vermaxik commented 6 months ago

@isidentical any progress here? 🙏

Ousret commented 6 months ago

It's fixed in PR https://github.com/httpie/cli/pull/1531 If you want to try it out: pip install "git+https://github.com/Ousret/HTTPie.git@feature-tryout-niquests" -U