fix(apiform): strip path components from upload filenames - #120
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
fix(apiform): strip path components from upload filenames#120sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
sylvesterkaczmarek
force-pushed
the
fix/apiform-upload-basename
branch
from
August 20, 2026 20:38
ff7e2ed to
8095fae
Compare
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.
Summary
Ensure multipart uploads send only the basename of reader-provided file paths, regardless of whether the path uses POSIX or Windows separators.
Problem
internal/apiform.encodeReaderderives filenames from readers exposingName()withpath.Base, which only treats/as a separator. A Windows-style name such asC:\dir\report.pdfcan therefore remain unchanged when processed on a non-Windows host or supplied by a cross-platform/custom reader, placing directory components in the multipartfilename=parameter instead of justreport.pdf.Fix
Normalize backslash separators before taking the path basename. POSIX paths keep their existing behavior, while Windows-style paths reduce to the same basename representation.
The change is limited to the
Name()fallback. Readers that explicitly implementFilename()retain control of the filename they provide.Regression coverage
Added table-driven multipart tests covering POSIX and Windows-style paths. Both must produce
filename="report.pdf", and the serialized body must not contain directory components.Validation
The branch is based directly on current upstream
main(a7719136b8ed401b0c51a05553a5e4f720150307) and contains one DCO-signed commit touching only the multipart encoder plus focused regression coverage. Full repository test execution is left to CI.Risk
Low. Only the fallback filename derived from a reader's
Name()changes, and only by removing directory components. File contents, content type handling, explicitFilename()implementations, field names, and non-file multipart fields are unchanged.