Repository navigation
Conversation
The body regex matches a delimiter after a CRLF, or with no CRLF at the scan position. The scan position is the start of a part body, and also the start of the data the parser keeps when it trims its buffer between reads, which can fall anywhere inside a body. Content with "--boundary\r\n" and no CRLF before it at that offset ends the part there. The parser used to skip two bytes after every match and jump to the next delimiter, which truncated the upload. With the CRLF skipped only when present, the bytes after the false delimiter are parsed as a new part, and an uploaded file can add parameters. Accept a delimiter without a CRLF only until body bytes have been passed to the collector, and require the CRLF after that. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
wtn
marked this pull request as ready for review
October 30, 2026 20:06
wtn
force-pushed
the
multipart-empty-part-delimiter
branch
from
October 30, 2026 20:08
7fee39a to
7745eef
Compare
This branch has not been deployed
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.
For PR rack#2541.
@body_regexis/(?:\r\n|\A)--BOUNDARY(?:\r\n|--)/, so a delimiter matches after a CRLF, or with no CRLF at the scan position. rack#2541 relies on the second case for a part with no body. The scan position is also where the retained data starts afterhandle_mime_bodytrims the buffer between reads, which can be anywhere inside a part body.On main, file content with
--BOUNDARY\r\nand no CRLF before it at that offset truncates the upload. With rack#2541's change to the CRLF skip, the bytes after it are parsed as a new part, so the content of an uploaded file can add a parameter:With default settings, the offset is
BUFSIZEminus the first part's headers minusboundary.bytesize + 6, so a plainRack::Request#POSTreaches it.This change accepts a delimiter without a CRLF only until body bytes have been passed to the collector, and requires the CRLF after that. The changelog entry for rack#2541 now mentions it.
Types of Changes
Contribution