Repository navigation
feat: add opt-in percent-decoded multipart filename accessor - #1497
Merged
pjfanning merged 2 commits intoNov 18, 2026
Merged
Conversation
Motivation: RFC 7578 allows senders to percent-encode non-ASCII form-data filenames, and apache#1494 added a client-side PercentEncoded option, but servers could only read the raw filename. Modification: Add Scala percentDecodedFilename and Java getPercentDecodedFilename to form-data body parts. They decode UTF-8 percent-escapes and return the raw value when it is not valid percent-encoded UTF-8. filename and getFilename are unchanged. Document the accessor in the HTTP model docs. Result: Applications can opt in to reading percent-encoded filenames. Tests: - MultipartSpec, MultipartFilenameTest, MultipartUnmarshallersSpec References: Fixes apache#1496
pjfanning
force-pushed
the
multipart-percent-decoded-filename
branch
from
November 18, 2026 09:32
bd11e04 to
0bb93b7
Compare
He-Pin
approved these changes
Nov 18, 2026
He-Pin
added a commit
that referenced
this pull request
Nov 28, 2026
Motivation: Existing multipart cases cover ordered same-name files and optional filename decoding but not literal consecutive ASCII spaces in filenames. Modification: Round-trip one short modeled multipart part through strict and streamed form data. Assert the quoted filename in strict output and compare the complete decoded part, including the name, content, and filename. Result: Both entity forms protect the existing behavior of preserving both spaces. No production code, API, or network behavior changes. Tests: - JDK 17, Scala 2.13.18 and 3.3.9: 8/8 each across the two MultipartUnmarshallersSpec suite classes, including the new round-trip in each and the adjacent same-name and percent-decoding controls. Exact test source was compiled against source-matching cached runtime classes. The new fixture uses the normal renderer's CRLF in both suites. - Scoped Scalafmt 3.11.5 and git diff --check passed. - Full sbt CI was not run. References: Refs #1483 and #1497; RFC 7578 Section 4.2.
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.
Motivation
RFC 7578 section 4.2 allows senders to percent-encode non-ASCII form-data filenames, and #1494 added a client-side
PercentEncodedoption. On the server,filename/getFilenameonly return the raw value, so a percent-encoded filename sent by a Pekko client cannot be read back as the original name.Modification
Multipart.FormData.BodyPart.percentDecodedFilenameand a JavagetPercentDecodedFilename()default method. They percent-decode thefilenameparameter as UTF-8 and return the raw value when it is not valid percent-encoded UTF-8 (e.g.100%.txt,caf%E9.txt).filename/getFilenameunchanged. Decoding is opt-in because a literal%is valid in filenames.100%.txtfor theExtendedandAsciiencodings. It now covers all three.Result
Servers can opt in to reading percent-encoded filenames, so Pekko client to Pekko server round-trips with
PercentEncoded.Tests
sbt "http-core/Test/testOnly org.apache.pekko.http.scaladsl.model.MultipartSpec org.apache.pekko.http.javadsl.model.MultipartFilenameTest": passed (decoding cases including invalid escapes and invalid UTF-8;100%.txtwith every filename encoding; Java default method).sbt "http-tests/Test/testOnly org.apache.pekko.http.scaladsl.unmarshalling.MultipartUnmarshallersSpec*": 84 passed (CRLF and LF), including decoding from wire bytes.sbt http-core/mimaReportBinaryIssues,javafmtCheckAll,http-core/scalafmtCheckAll,http-tests/scalafmtCheckAll: passed.References
Fixes #1496. Refs #1494, #1478.