Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyramid non-ascii formdata file upload doesn't work as expected #196

Open
inkhey opened this issue Nov 7, 2019 · 0 comments
Open

Pyramid non-ascii formdata file upload doesn't work as expected #196

inkhey opened this issue Nov 7, 2019 · 0 comments
Labels

Comments

@inkhey
Copy link
Contributor

inkhey commented Nov 7, 2019

When using pyramid backend and formdata file upload, we may have trouble with utf8 or other non-ascii encoded filename, in api depending on the client implementation of file upload

This is because we need to get a cgi.fieldstorage object. As explain in this issue:
https://stackoverflow.com/questions/42213318/cgi-fieldstorage-with-multipart-form-data-tries-to-decode-binary-file-as-utf-8-i
in case there is no "filename" field decoding of file is not processed as expected and will not be correctly handled as a files by pyramid.

This trouble happened because in case a file is utf8 encoded, RFC6266 say we should use filename* instead of filename in content-disposition of form when encoding is not utf8. requests python library and httpie command line do only set filename* in the utf8 filename case, but not filename.

There is an issue in cgi lib here about handling properly filename* in cgi.FieldStorage file:
https://bugs.python.org/issue23434
and a PR proposal here:
python/cpython#6027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant