Skip to content

Unnecessary quotes around encoded filename* parameter #8537

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

Closed
xanto521 opened this issue May 25, 2020 · 10 comments · Fixed by #9206 or #9222
Closed

Unnecessary quotes around encoded filename* parameter #8537

xanto521 opened this issue May 25, 2020 · 10 comments · Fixed by #9206 or #9222

Comments

@xanto521
Copy link

Describe the bug
When I was using this app, I found that the file name I uploaded in the form would have a double quote symbol in the file name obtained in the back end

Screenshots
this is the app ui
微信截图_20200525135443

this is python flask function request.files.get() get
微信截图_20200525135845

Why is there a double quote after the file name?

App information:

  • App Type :
    Postman for windows desktop
  • Postman Version
    7.24.0
  • OS:
    windows 10 Professional version 1909
@codenirvana
Copy link
Member

@a66298458 This doesn't look like an issue from Postman as it forwards the filename as-is.
You can confirm this by checking the filename= attribute sent in the raw log of the Postman console.

@xanto521
Copy link
Author

@a66298458 This doesn't look like an issue from Postman as it forwards the filename as-is.
You can confirm this by checking the filename= attribute sent in the raw log of the Postman console.

@codenirvana
when i use web ui to upload file , there is no this problem

when i use Progress Telerik Fiddler Web Debugger to check data, i find a different place

this is the form data from web ui upload
微信截图_20200526171311

this is the form data from postman upload
微信截图_20200526171429

i think this is the key of the problem, but i can't find how to fixed that.

@codenirvana
Copy link
Member

@a66298458 I see no issue in the Content-Disposition headers and the filename is set correctly.
Probably, the server is not able to process the filename* attribute which is added because of the non-ASCII file name.

Which server/form-data body-parser are you using to process this?
Check if uploading a filename with just ASCII characters works fine for you.

@codenirvana codenirvana self-assigned this May 26, 2020
@xanto521
Copy link
Author

@codenirvana i use python flask webserver , the api is request.files.get('upload_file')

from flask import request
request.files.get('upload_file')

@codenirvana
Copy link
Member

@a66298458 I tried reproducing this issue using a flask server and looks like its body-parser is not able to process the filename* attribute in Content-Disposition header.
Also, the library which is used internally recommends using the Unicode characters in the filename.

Closing this issue as we are already tracking this feature request of disabling the filename* attribute here: #8308

@itsjef
Copy link

itsjef commented Jun 4, 2020

@codenirvana I'm having this issue too. It happens specially when uploading a file whose name contains non-ASCII character (blue circle). Uploading from web-form or command line (using cURL or httpie) is fine.

image

App info:

  • Postman for windows desktop
  • Postman Version: v7.25.2
  • OS: Windows 10

@itsjef
Copy link

itsjef commented Jun 4, 2020

Looks like it happens specially to Flask and libraries built on top of it (Eve, Flask-RESTful...). I created another server with Sanic and the filename returned correctly. :)

@codenirvana
Copy link
Member

@itsjef As mentioned in #8537 (comment), Postman implements RFC 6266 which introduces this new filename * disposition parameter for Non-ASCII file names.

A lot of body-parsers don't support this yet but if you check the Content-Disposition header set by Postman, it includes both filename and filename* parameters for backward compatibility.

Content-Disposition: form-data; name="file"; filename="你好.xlsx"; filename*="UTF-8''%E4%BD%A0%E5%A5%BD.xlsx"

But looks like Flask's body-parser has a different way to extract the filename from the Content-Disposition header.

We are already tracking a feature request #8308 which will allow you to disable filename * addition.

@obfusk
Copy link

obfusk commented Jun 6, 2020

Actually, I think it is a bug in postman. Looking at the example:

Content-Disposition: form-data; name="file"; filename="你好.xlsx"; filename*="UTF-8''%E4%BD%A0%E5%A5%BD.xlsx"

And looking at the relevant RFCs (https://tools.ietf.org/html/rfc6266 & https://tools.ietf.org/html/rfc5987), I notice that filename*= does not support quoted-string values -- only percent-encoding -- whereas the example combines both. When removing the non-RFC-compliant quotes, the example seems to work just fine with flask:

Content-Disposition: form-data; name="file"; filename="你好.xlsx"; filename*=UTF-8''%E4%BD%A0%E5%A5%BD.xlsx

@codenirvana codenirvana reopened this Jun 14, 2020
@codenirvana codenirvana changed the title Why is there a double quote in the uploaded file name? Unnecessary quotes around encoded filename* parameter Jun 14, 2020
@arlemi
Copy link
Collaborator

arlemi commented Oct 29, 2020

We had to delay the release of the app, I'm reopening this issue for now and will close it again once 7.35 is widely available. 🙂

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