Skip to content

fix(core): avoid char-boundary panic in decode_entities - #54

Merged
mahype merged 1 commit into
mahype:mainfrom
staude:fix/entity-char-boundary
Oct 2, 2026
Merged

mahype merged 1 commit into
mahype:mainfrom
staude:fix/entity-char-boundary

Conversation

@staude

@staude staude commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #53

Problem

decode_entities schnitt den String für die Suche nach dem ; an einer festen Byte-Position (12) ab. Liegt dort ein Mehrbyte-Zeichen wie ä, paniciert Rust – beim Neuaufbau des Such-Caches crasht TorroMail.

Fix

Das ; wird jetzt byteweise im 12-Byte-Fenster gesucht. Da ; ASCII ist, ist der gefundene Index immer eine gültige Zeichengrenze.

Test

  • Neuer Regressionstest an_ampersand_before_multibyte_text_does_not_panic. Er schlägt mit dem alten Code fehl und läuft mit dem Fix durch.
  • cargo test -p torromail-core mime: alle Tests grün.

🤖 Generated with Claude Code

The entity terminator search sliced the string at a fixed 12-byte
offset, which panics when a multi-byte character straddles it (e.g.
"& Kuchen, Säfte"). Search the bytes for `;` instead.

Fixes mahype#53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mahype
mahype merged commit 621fde5 into mahype:main Oct 2, 2026
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.

Panic in decode_entities: Byte-Index 12 liegt in Mehrbyte-Zeichen

2 participants