Skip to content

textproto: fix boundary prefix collision causing empty part bodies - #13

Merged
mpasquale-3 merged 5 commits into
masterfrom
mpasquale-fix-boundary-prefix-collision
Aug 24, 2026
Merged

textproto: fix boundary prefix collision causing empty part bodies#13
mpasquale-3 merged 5 commits into
masterfrom
mpasquale-fix-boundary-prefix-collision

Conversation

@mpasquale-3

@mpasquale-3 mpasquale-3 commented Aug 21, 2026

Copy link
Copy Markdown

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:
matchAfterPrefix previously 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...J and an inner boundary is S0p-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. scanUntilBoundary then reports an empty part body at byte 0, so mdm.Body is nil even though the EML contains HTML content.

Fix

When matchAfterPrefix sees c == '-', peek one more byte to distinguish the two cases:

  • Next byte is also - → genuine closing delimiter
  • Next byte is anything else → longer boundary, not a match

…ner boundary

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mpasquale-3
mpasquale-3 force-pushed the mpasquale-fix-boundary-prefix-collision branch from 2ca4e96 to 66d16d7 Compare August 21, 2026 23:57
mpasquale-3 and others added 2 commits August 21, 2026 17:01
…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 mpasquale-3 changed the title [CLAUDE DRAFT] textproto: fix boundary prefix collision causing empty part bodies textproto: fix boundary prefix collision causing empty part bodies Aug 22, 2026
@mpasquale-3
mpasquale-3 marked this pull request as ready for review August 22, 2026 00:17
@mpasquale-3
mpasquale-3 requested a review from a team August 22, 2026 00:17
mongoose700
mongoose700 previously approved these changes Aug 24, 2026
Comment thread textproto/multipart_test.go Outdated
Comment thread textproto/multipart.go
Comment thread textproto/multipart_test.go Outdated
…est tabular

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o5 variables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mpasquale-3
mpasquale-3 merged commit 7ec6c29 into master Aug 24, 2026
3 checks passed
@mpasquale-3
mpasquale-3 deleted the mpasquale-fix-boundary-prefix-collision branch August 24, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants