Skip to content

uri-encode filename because of rfc6266 section-4.3#2245

Open
fuminori-ido-m wants to merge 1 commit into
dropzone:mainfrom
fuminori-ido-m:main
Open

uri-encode filename because of rfc6266 section-4.3#2245
fuminori-ido-m wants to merge 1 commit into
dropzone:mainfrom
fuminori-ido-m:main

Conversation

@fuminori-ido-m
Copy link
Copy Markdown

Issue

It is treated as URI-encoded already when filename contains '%' so that the when original filename contains '%' like a-%61.txt then it is converted to a-a.txt at server-side.

Reason

According to RFC6266 section-4.3, filename should be uri-encoded in form-data while in dropzone.js FormData append part passes raw filename via _renameFile() as follows in src/dropzone.js:

_renameFile(file) {
...
return file.name;
...
filename: this._renameFile(file),
...
formData.append(dataBlock.name, dataBlock.data, dataBlock.filename);

Solution

This PR encode by encodeURIComponent() at _renameFile when renameFile hook is not defined.

(I didn't touch user-customized renameFile() so that user need to take care about '%' issue mentioned above.)

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

Successfully merging this pull request may close these issues.

1 participant