Repository navigation
Conversation
RFC 2047 §6.2 joins adjacent encoded-words separated only by linear
whitespace and discards the separator: it is there so a long word can be
folded, not as part of the text. `mail_parser` decodes both words but keeps
the whitespace inside parameter values, so a file announced as
Content-Disposition: attachment; filename="=?utf-8?q?docu?= =?utf-8?q?ment.pdf?="
arrives named `docu ment.pdf`.
With no `.pdf` suffix `guess_mime` falls through to
`application/octet-stream`, so the file draws no PDF thumbnail and opens in
nothing. A header folded between the encoded-words leaves a tab instead of a
space, with the same result.
This can't be repaired after the fact: the decoded string no longer shows
where one encoded-word ended, and a space in a filename is often genuine.
Splice the pair in the raw header instead — reachable through the part's
public header offsets — and hand the repaired header back to `mail_parser`,
so charset handling stays in one place. The second parse only runs when a
splice actually changed something.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hyprlab
added a commit
that referenced
this pull request
Sep 3, 2026
RFC 2047 §6.2 joins adjacent encoded-words separated only by linear whitespace and discards the separator: it is there so a long word can be folded, not as part of the text. `mail_parser` decodes both words but keeps the whitespace inside parameter values, so a file announced as two spliced encoded-words arrives named `docu ment.pdf` — no `.pdf` suffix, so no thumbnail and nothing to open it with. A header folded between the words leaves a tab instead of a space, same result. Once decoding has happened the boundary is gone, and a space in a filename is often genuine — so the repair splices the raw header bytes (`?=` whitespace `=?` is pure ASCII, safe to scan) and hands the fixed Content-Disposition and Content-Type back to mail_parser, keeping every charset decision in one place. The second parse only runs when a splice changed something. Landed from #118, resolving a test-module conflict with #110's landing. The contributor intends to report the underlying behaviour to mail_parser upstream; this workaround can come out if that lands. Co-Authored-By: Alexander Lubovenko <2742734+typedev@users.noreply.github.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ay7c8wSGyaTPNuDXShNgAw
hyprlab
added a commit
that referenced
this pull request
Sep 3, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ay7c8wSGyaTPNuDXShNgAw
hyprlab
added a commit
that referenced
this pull request
Sep 3, 2026
…andles Feature beta previewing 1.20.0. See CHANGELOG.md for the full list: composer spell checking with bundled dictionaries and a managed personal word list (discussion #114), inline images in the composer (discussion #113), replies that follow Reply-To, the split reply and attachment drawer resized by a floating grab pill, paste-as-plain-text by default, the wide-mail scroll fix, and the three attachment fixes from #110, #112 and #118 with a one-time cache repair. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ay7c8wSGyaTPNuDXShNgAw
Owner
|
Landed in stable 1.20.0 as commit 9ab2fa1 on main, with you as co-author. Thank you. Applied as written. Closing since the commit is on main rather than merged from the branch. |
hyprlab
added a commit
that referenced
this pull request
Sep 24, 2026
…andles Feature beta previewing 1.20.0. See CHANGELOG.md for the full list: composer spell checking with bundled dictionaries and a managed personal word list (discussion #114), inline images in the composer (discussion #113), replies that follow Reply-To, the split reply and attachment drawer resized by a floating grab pill, paste-as-plain-text by default, the wide-mail scroll fix, and the three attachment fixes from #110, #112 and #118 with a one-time cache repair.
somepaulo
pushed a commit
to somepaulo/hylki
that referenced
this pull request
Sep 24, 2026
RFC 2047 §6.2 joins adjacent encoded-words separated only by linear whitespace and discards the separator: it is there so a long word can be folded, not as part of the text. `mail_parser` decodes both words but keeps the whitespace inside parameter values, so a file announced as two spliced encoded-words arrives named `docu ment.pdf` — no `.pdf` suffix, so no thumbnail and nothing to open it with. A header folded between the words leaves a tab instead of a space, same result. Once decoding has happened the boundary is gone, and a space in a filename is often genuine — so the repair splices the raw header bytes (`?=` whitespace `=?` is pure ASCII, safe to scan) and hands the fixed Content-Disposition and Content-Type back to mail_parser, keeping every charset decision in one place. The second parse only runs when a splice changed something. Landed from hyprlab#118, resolving a test-module conflict with hyprlab#110's landing. The contributor intends to report the underlying behaviour to mail_parser upstream; this workaround can come out if that lands. 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
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.
Fixes #117.
RFC 2047 §6.2 joins adjacent encoded-words separated only by linear whitespace and discards the separator: it is there so a long word can be folded, not as part of the text.
mail_parserdecodes both words but keeps the whitespace inside parameter values, so a file announced asarrives named
docu ment.pdf. With no.pdfsuffixguess_mimefalls through toapplication/octet-stream, so the file draws no PDF thumbnail and opens in nothing. A header folded between the encoded-words leaves a tab instead of a space, with the same result.Why it happens in the raw header
Once
attachment_name()has returned the decoded string, the encoded-word boundaries are gone — and a space in a filename is often genuine, so there is nothing left to distinguishdocu ment.pdffrommy file.pdf. The repair has to happen while the raw header is still in hand.MessagePart::headersexposes each header'soffset_start/offset_endinto the raw message, so the original bytes are reachable.attachment_name_ofsplices adjacent encoded-words there and hands the repaired Content-Disposition and Content-Type back tomail_parser, which keeps every charset decision in one place rather than reimplementing RFC 2047 here.The splice scan works on bytes directly:
?=,=?and the whitespace are all ASCII, which never occurs inside a multi-byte UTF-8 sequence.Cost
The second parse only runs when a splice actually changed something, so ordinary mail pays one comparison and nothing else.
Tests
a_filename_split_across_encoded_words_is_rejoined— the space form.a_filename_folded_between_encoded_words_is_rejoined— the same split folded, so the separator is a tab.a_space_inside_one_encoded_word_is_kept—=?utf-8?q?my=20file.pdf?=keeps its space; that one is in the name, not between words.an_unencoded_filename_with_a_space_is_untouched— a plainfilename="my file.pdf"is left alone.The last two are the guard rails: the repair must not start eating real spaces.
Full suite: 251 passed, 0 failed.
Note
Arguably this belongs in
mail_parserrather than here — I intend to report it upstream too. The workaround is self-contained and can come out again if that lands.