originalname is not properly decoded
See original GitHub issueIf uploaded file name contains special characters, the originalname will be set in encoded form.
Steps to repro:
- upload file named ‘file".ext’
- expected originalname = ‘file".ext’
- actual originalname = ‘file%22.ext’
Additional info from browser side:
Headers:
method: POST
content-type: multipart/form-data; boundary=----WebKitFormBoundaryBc2l7WXbILSFIgKL
...
Data:
------WebKitFormBoundaryBc2l7WXbILSFIgKL
Content-Disposition: form-data; name="file"; filename="file%22.ext"
...
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Resolve damaged document error when opening PDF files
Workarounds to open PDF files that do not open in Adobe Acrobat after the 10.1.5 and 11.0.01 updates.
Read more >Can't decode accent properly in pandas dataframe
Can't decode accent properly in pandas dataframe ... returns 'TAfAPlzer' , not 'Tolzer' for the original name "Tölzer".
Read more >Topic: MS Edge takes over pdfs @ AskWoody
Sorry to hear that did not keep your pdfs from being taken over by Edge. ... cursor at the end of the highlighted...
Read more >(FAQ) Why won't VEGAS open my file correctly? Codecs ...
Many game capture and screen recording programs generate video that does not decode smoothly in VEGAS. Some of them use non-standard codecs ...
Read more >POST method uploads - Manual - PHP
$uploaddir = './'; is because if you have no coded file constraints a nerd could upload a php script with the same name...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this is my solution
the important part is that
Buffer.from(file.originalname, "latin1").toString("utf8")
@donghero that’s great! From my understanding it seems like HTTP headers are
latin1
unless otherwise specifiedref: https://www.jmix.io/blog/utf-8-in-http-headers/
It would probably be nice to add support for
filename*
as well though