Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use international headers when posting file names #119

Closed
gagern opened this Issue · 1 comment

2 participants

@gagern

RFC 2388 Section 4.4 states:

if the file name of the sender's operating system is not in US-ASCII, the file name might be approximated, or encoded using the method of RFC 2231.

Currently, urllib3 does neither. Instead, it will simply UTF-8 encode the file name. While many receiving parties might be able to handle that situation, it appears to me like a violation of the specification, with all the impact this might have on interoperability.

To be more precise, when encountering a non-ascii file name like Täst.txt, it should send a header like this:

Content-Disposition: form-data; name="fieldname"; file*=utf-8''T%C3%A4st.txt

The same holds for non-ascii names of form fields. You can use the email.utils.encode_rfc2231 function to perform this kind of header formatting. For increased portability, you might want to only do so for cases that actually require it, keeping the current syntax for ascii-only names.

@shazow
Owner

I've no objections to this if you'd like to send a pull request. :) Please include tests with any new code; urllib3 is trying to maintain 100% unit test coverage.

@gagern gagern referenced this issue from a commit in gagern/urllib3
@gagern gagern Handle non-ascii headers in multipart/form-data
Second stab at shazow/urllib3#119, now integrated with the RequestField
infrastructure.
7daa44a
@shazow shazow closed this
@shazow shazow referenced this issue from a commit
@shazow Added #119 to CHANGES. 4c38048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.