textproto: fix boundary prefix collision causing empty part bodies - #13
Merged
Merged
Conversation
…ner boundary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mpasquale-3
force-pushed
the
mpasquale-fix-boundary-prefix-collision
branch
from
August 21, 2026 23:57
2ca4e96 to
66d16d7
Compare
…oundary levels Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ry level Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mpasquale-3
marked this pull request as ready for review
August 22, 2026 00:17
mongoose700
previously approved these changes
Aug 24, 2026
…est tabular Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o5 variables Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mongoose700
approved these changes
Aug 24, 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
We need the multipart parser to distinguish between closing boundaries (
--) and suffixed nested boundaries (-nestedSuffix). Nested multipart boundaries have been seen in real EMLs, and Apple Mail renders the body perfectly.Claude Summary:
matchAfterPrefixpreviously returned+1(boundary match) whenever the character immediately after the boundary prefix was-. The intent was to handle--boundary--(the closing delimiter), but this also matched--boundary-suffix— a longer, different inner boundary.In practice: if the outer boundary is
S0p-lc86...Jand an inner boundary isS0p-lc86...J-5, the outer part body reader encounters--S0p-lc86...J-5\n, matches the outer boundary prefix, sees-as the next character, and returns+1.scanUntilBoundarythen reports an empty part body at byte 0, somdm.Bodyis nil even though the EML contains HTML content.Fix
When
matchAfterPrefixseesc == '-', peek one more byte to distinguish the two cases:-→ genuine closing delimiter