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

handling defined filename encoding in Content-Disposition #1694

Closed
1 task done
pawciobiel opened this issue Mar 1, 2018 · 1 comment
Closed
1 task done

handling defined filename encoding in Content-Disposition #1694

pawciobiel opened this issue Mar 1, 2018 · 1 comment

Comments

@pawciobiel
Copy link
Contributor

pawciobiel commented Mar 1, 2018

  • I'm submitting a ...
  • bug report
  • 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

@webknjaz
Copy link
Member

webknjaz commented Sep 9, 2018

Fixed by #1695

@webknjaz webknjaz closed this as completed Sep 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants