Repository navigation
Do not quote the filename* parameter in multipart Content-Disposition - #3337
Merged
arturobernalg merged 1 commit intoDec 4, 2026
Merged
Conversation
RFC 8187 ext-value is a token, not a quoted-string. Express/multer (busboy) drops the file part and Flask (Werkzeug) returns the literal quoted string as the file name when filename* is quoted.
ok2c
approved these changes
Dec 4, 2026
Member
@arturobernalg Would you have time to take a look? |
arturobernalg
approved these changes
Dec 4, 2026
arturobernalg
left a comment
Member
There was a problem hiding this comment.
LGTM. Thank you @shinseongsu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm Korean, and most of the files we upload have Korean names. Since 5.5, uploading a file like
월간 보고서.pdfwithMultipartEntityBuilderbreaks on some very common servers: the request returns 200, but the file is either gone or saved under a garbage name.The cause is the quotes around the
filename*value added in #618:In RFC 8187 (section 3.2.1)
ext-valueis a token, not a quoted-string, and the RFC 6266 examples are unquoted too. Tomcat tolerates the quotes, but busboy (multer) and Werkzeug do not.Client code (default mode):
What the server receives (all responses are 200):
?? ???.pdf월간 보고서.pdf월간 보고서.pdf?? ???.pdf월간 보고서.pdf?? ???.pdf"UTF-8''%EC%9B%94...pdf"월간 보고서.pdfThe multer case is the one that hurt: the upload looks successful and the file is silently dropped.
Change
filename*is now written without quotes inMimeField#getBody(used by the default STRICT mode, and also by LEGACY and non form-data EXTENDED) and inHttpRFC7578Multipart(EXTENDED form-data). InMimeFieldthe quotes are dropped only when the value already has theUTF-8''prefix (that is always the case for values produced byFormBodyPartBuilder). Anything else keeps the old quoted output.When
filename*is emitted, and the encoding itself, are unchanged from #618. Only the two quote characters go away, soContent-Lengthshrinks by 2 bytes for each part that hasfilename*. ASCII and Latin-1 file names produce exactly the same bytes as before.Tests
TestMultipartEntityBuilderthat expected the quoted form.testDefaultModeNonLatinFilenameWritesUnquotedFilenameStarfor the default mode, which had nofilename*test.httpclient5verify passes.Question
A value passed in by the user as
filename*throughaddFieldis passed through as is if it starts withUTF-8''. Before this change it was at least wrapped in quotes. Would you like me to also validate it against the RFC 8187ext-valuegrammar here (and percent-encode it otherwise)? Or is that better left for a separate change?