Keep multipart header separators inside completed parts - #4
Open
kunal26das wants to merge 2 commits into
Open
Conversation
kunal26das
added this pull request to stack #7
September 10, 2026 21:26
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
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.This native fork PR mirrors the upstream native multipart bounds submission as layer 4 of six. This layer is based on gradient calculations. The registered fork stack uses dependent PR bases, so this PR shows its incremental diff.
Stack order: Foundation → RNTester dependencies → Gradients → Native multipart bounds → Shared multipart parsing → Scroll offsets.
The existing Okio deprecation-suppression annotation from
35db533908cis placed with its regression in this layer. The native fix and annotation match the independently validated upstream submission; moving the annotation earlier leaves the final multipart and scroll source trees unchanged. The test results below retain their original source provenance and do not claim new execution solely from restacking.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.