Keep multipart header separators inside completed parts - #58473
Open
kunal26das wants to merge 2 commits into
Open
Keep multipart header separators inside completed parts#58473kunal26das wants to merge 2 commits into
kunal26das wants to merge 2 commits into
Conversation
This was referenced Sep 10, 2026
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
Native stacked review: Review this layer in the registered six-PR fork stack. This PR remains the upstream submission to
react/react-native.A multipart body ending in CRLF can produce a CRLFCRLF match that starts in the body and ends in the following boundary.
MultipartStreamReadercurrently checks only the start of the match, then treats it as a header separator inside the completed part. This can create a negative body length and fail a development bundle download.Require the entire header separator to lie inside the part. Add a regression that reads the response at every possible chunk size, including binary content and boundary-like body bytes.
This is an existing native Android defect found while evaluating shared multipart parsing. The fix and regression are independent of Kotlin Multiplatform.
Changelog:
[ANDROID] [FIXED] - Keep multipart header separators inside their completed part.
Test Plan
MultipartStreamReaderTestJUnit class with the original parser plus the new regression: the regression fails with negative body length.The assembled follow-up stack also passed the full ReactAndroid suite: 623 tests across 94 suites, zero failures/errors/skips. That run includes this bounds fix and regression, the shared multipart adapter, and other stack changes; it is not an isolated run of this PR. The regression suppresses a compile-time deprecation error to retain the reader's existing Okio 2.9 API usage.
The repository test entry point is
:packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.devsupport.MultipartStreamReaderTest.