-
Do you want to request a feature or report a bug?
I'd like to report a bug because this appears to me as undocumented and undesired behaviour,
but I understand that this could also be feature request.
-
What is the current behavior?
When POSTing a file containing non ASCII characters in it's name, using Content-Type: multipart/form-data
and Content-Disposition with defined encoding:
form-data; name="myFile"; filename*=utf-8''upload_test_file_%C5%82%C3%B3%C4%85%C3%A4.txt
when accessing upload in POST handler like myFile.filename
I get file content instead of it's name.
- If the current behavior is a bug, please provide the steps to reproduce and if possible a screenshots and logs of the problem.
import requests
fn = '/tmp/test_\xc5\x82\xc3\xb3\xc4\x85\xc3\xa4.po'
with open(fn, 'rb') as fh: r = requests.post(url, files={'myFile': fh})
- What is the expected behavior?
I think that the best way would be to handle encoding and return name as unicode object
but if this isn't possible, perhaps return HTTP 400 Bad Request or at least throw NotImplementedError which would be returned as HTTP 500?
def POST(self, myFile):
fname = myFile.filename # should contain python unicode
- What is the motivation / use case for changing the behavior?
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
https://tools.ietf.org/html/rfc5987
- Please tell us about your environment:
- Cheroot version: 6.0.0
- CherryPy version: 14.0.0
- Python version: 2.7
- OS: linux
- Browser: [requests ]
- Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, e.g. stackoverflow, gitter, etc.)
https://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http
Do you want to request a feature or report a bug?
I'd like to report a bug because this appears to me as undocumented and undesired behaviour,
but I understand that this could also be feature request.
What is the current behavior?
When POSTing a file containing non ASCII characters in it's name, using Content-Type: multipart/form-data
and Content-Disposition with defined encoding:
form-data; name="myFile"; filename*=utf-8''upload_test_file_%C5%82%C3%B3%C4%85%C3%A4.txtwhen accessing upload in POST handler like
myFile.filenameI get file content instead of it's name.
I think that the best way would be to handle encoding and return name as unicode object
but if this isn't possible, perhaps return HTTP 400 Bad Request or at least throw NotImplementedError which would be returned as HTTP 500?
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
https://tools.ietf.org/html/rfc5987
https://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http