8000 A non-ASCII part header no longer takes the account's mail thread down by typedev · Pull Request #216 · hyprlab/hylki · GitHub
[go: up one dir, main page]

Skip to content

A non-ASCII part header no longer takes the account's mail thread down - #216

Closed
typedev wants to merge 1 commit into
hyprlab:mainfrom
typedev:fix/mime-header-char-boundary
Closed

typedev wants to merge 1 commit into
hyprlab:mainfrom
typedev:fix/mime-header-char-boundary

Conversation

@typedev
@typedev typedev commented Sep 17, 2026
Copy link
Copy Markdown
Contributor

Fixes #215.

mime_header found its header by slicing the line at the name's byte length and
comparing that slice as a str. A header block reaches it through
String::from_utf8_lossy, so a line can carry a multibyte character straddling
that offset — and the slice panics rather than simply not matching. The length
guard above it compares bytes, so it lets such a line through.

The panic lands on the account's mail thread, which is where the whole account's
IMAP work happens: it dies, every request in flight goes unanswered, and that
account's wheel turns for good while the other accounts carry on. The preview
passes reach this code with raw, truncated MIME on every sync and re-read the
same rows each time, so once one message qualifies the account never syncs
again.

Compare as bytes instead. A header name is ASCII, so a byte-wise match also
proves the offset is a character boundary, which is what makes the slice on the
next line safe — no other behaviour changes, since a line that used to panic is
one that could never have matched.

Tests

Two regression tests in src/worker.rs:

  • a_header_line_with_a_multibyte_character_is_not_sliced_apart — the
    comparison itself, on a header block whose first line puts a two-byte
    character across byte 25.
  • a_preview_survives_a_multibyte_part_header — the same line reached the way
    production reaches it, as a part of a multipart read for a list preview.

Both reproduce the reported panic message verbatim when the fix is reverted, and
pass with it.

cargo test on this branch: 415 passed, 4 failed. The four are
tray::tests::{every_icon_renders_at_every_size, a_half_fill_leaves_a_clear_margin_and_moves_the_dot, the_dot_is_red_and_only_when_asked}
and ui::message_view::tests::a_card_from_your_own_mailbox_wears_that_mailboxs_face.
They fail identically on a clean main here and are an artefact of this
environment, not of the change: gdk-pixbuf in GNOME runtime 50 decodes through
glycin, which spawns its loader with flatpak-spawn --sandbox, and that is not
available in the plain org.gnome.Sdk//50 shell used to run the suite. Their own
pass was not witnessed here.

🤖 Generated with Claude Code

`mime_header` found its header by slicing the line at the name's length
and comparing that as a string. A header block reaches it through
`from_utf8_lossy`, so a line can carry a multibyte character straddling
that offset — and the slice panics rather than simply not matching. The
length guard above it compares bytes, so it lets such a line through.

The panic lands on the account's mail thread, which is where the whole
account's IMAP work happens: it dies, every request in flight goes
unanswered, and the account's spinner turns for good while the other
accounts carry on. The preview repair pass added in 1.27 reaches this
code with raw, truncated MIME on every sync, and it re-reads the same
rows each time, so once one message qualifies the account never syncs
again.

Compare as bytes instead. A header name is ASCII, so a byte-wise match
also proves the offset is a character boundary, which is what makes the
slice on the next line safe.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hyprlab added a commit that referenced this pull request Sep 17, 2026
#215)

`mime_header` found its header by slicing the line at the name's byte
length and comparing that slice as a `str`. A header block reaches it
through `String::from_utf8_lossy`, so a line can carry a multibyte
character straddling that offset, and the slice panics rather than
simply not matching. The length guard above it compares bytes, so it
lets such a line through.

The panic lands on the account's mail thread, where the whole account's
IMAP work happens: it dies, every request in flight goes unanswered, and
that account's wheel turns for good while the other accounts carry on.
The preview passes reach this code with raw, truncated MIME on every
sync and re-read the same rows each time, so once one message qualifies
the account never syncs again.

Compare as bytes instead. A header name is ASCII, so a byte-wise match
also proves the offset is a character boundary, which is what makes the
slice on the next line safe. No other behaviour changes, since a line
that used to panic is one that could never have matched. Two regression
tests reproduce the reported panic when the fix is reverted.

Landed from PR #216.

Co-Authored-By: Alexander Lubovenko <2742734+typedev@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hyprlab
hyprlab commented Sep 17, 2026
Copy link
Copy Markdown
Owner

Landed on main as ec7ae6a with your credit and shipped in 1.33.1. Nothing was changed on the way in: the byte-wise comparison, the comment and both tests are as you wrote them.

The four tests you could not run in the SDK shell pass on a host with a working pixbuf, so the whole suite is green here. Thank you!

@hyprlab hyprlab closed this Sep 17, 2026
hyprlab added a commit that referenced this pull request Sep 17, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@typedev
8000
typedev deleted the fix/mime-header-char-boundary branch September 17, 2026 19:28
somepaulo pushed a commit to somepaulo/hylki that referenced this pull request Sep 24, 2026
hyprlab#215)

`mime_header` found its header by slicing the line at the name's byte
length and comparing that slice as a `str`. A header block reaches it
through `String::from_utf8_lossy`, so a line can carry a multibyte
character straddling that offset, and the slice panics rather than
simply not matching. The length guard above it compares bytes, so it
lets such a line through.

The panic lands on the account's mail thread, where the whole account's
IMAP work happens: it dies, every request in flight goes unanswered, and
that account's wheel turns for good while the other accounts carry on.
The preview passes reach this code with raw, truncated MIME on every
sync and re-read the same rows each time, so once one message qualifies
the account never syncs again.

Compare as bytes instead. A header name is ASCII, so a byte-wise match
also proves the offset is a character boundary, which is what makes the
slice on the next line safe. No other behaviour changes, since a line
that used to panic is one that could never have matched. Two regression
tests reproduce the reported panic when the fix is reverted.

Landed from PR hyprlab#216.

Co-Authored-By: Alexander Lubovenko <2742734+typedev@users.noreply.github.com>
somepaulo pushed a commit to somepaulo/hylki that referenced this pull request Sep 24, 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.

A non-ASCII MIME part header panics the account's mail thread, and that account never syncs again

2 participants

0