fix(fetch): parse multipart body up to the full boundary delimiter#5561
Open
arshsmith1 wants to merge 2 commits into
Open
fix(fetch): parse multipart body up to the full boundary delimiter#5561arshsmith1 wants to merge 2 commits into
arshsmith1 wants to merge 2 commits into
Conversation
Signed-off-by: arshiya tabasum <arshi@bugqore.com>
KhafraDev
requested changes
Jul 15, 2026
Comment on lines
+79
to
+82
| // The delimiter that terminates a part's body is the CRLF that precedes the | ||
| // next boundary delimiter line, i.e. "\r\n--boundary". Matching the full | ||
| // delimiter (not a bare boundary token) is required so boundary-like bytes | ||
| // inside a body are not mistaken for a delimiter. |
Member
There was a problem hiding this comment.
Suggested change
| // The delimiter that terminates a part's body is the CRLF that precedes the | |
| // next boundary delimiter line, i.e. "\r\n--boundary". Matching the full | |
| // delimiter (not a bare boundary token) is required so boundary-like bytes | |
| // inside a body are not mistaken for a delimiter. |
| t.assert.strictEqual(form.get('fiŝo'), 'value1') | ||
| }) | ||
|
|
||
| test('multipart formdata body containing the boundary token', async (t) => { |
Member
There was a problem hiding this comment.
please move this to test/busboy
Author
There was a problem hiding this comment.
Moved it to test/busboy/formdata-boundary-token.js.
Drop the explanatory comment on crlfDashBoundary and relocate the regression test out of client-fetch.js into test/busboy. Signed-off-by: arshiya tabasum <arshi@bugqore.com>
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.
This relates to...
Multipart parsing in
response.formData()/request.formData().Rationale
The body loop in
multipartFormDataParserlooked for a bare boundary token (boundary.subarray(2)) rather than the\r\n--boundarydelimiter line, then blindly subtracted 4 from the match index. A part whose body legitimately contains the boundary token gets truncated at the wrong offset, and in most cases the whole body is rejected withexpected CRLFeven though it is well framed. This block carried a// TODO: the steps here are completely wrongnote. The fix matches the full delimiter so boundary-like bytes inside a body are no longer mistaken for a delimiter, which also removes an ambiguity where such bytes could be read as an extra part.Changes
Search for
\r\n--boundarywhen terminating a part body and slice up to that index, instead of finding the bare boundary token and offsetting by 4.Features
N/A
Bug Fixes
Breaking Changes and Deprecations
N/A
Status