8000 List a small attachment the sender declared, Content-ID and all by typedev · Pull Request #110 · hyprlab/hylki · GitHub
[go: up one dir, main page]

Skip to content

List a small attachment the sender declared, Content-ID and all - #110

Closed
typedev wants to merge 1 commit into
hyprlab:mainfrom
typedev:fix/gmail-inline-cid-attachments
Closed

typedev wants to merge 1 commit into
hyprlab:mainfrom
typedev:fix/gmail-inline-cid-attachments

Conversation

@typedev
@typedev typedev commented Sep 2, 2026 •
Copy link
Copy Markdown
Contributor

Fixes #109.

extract_attachments dropped any part carrying a Content-ID and weighing under 64 KiB, to keep a newsletter's cid: logo out of the file list. It never looked at Content-Disposition, so a part the sender explicitly marked attachment was thrown away on size alone.

Gmail's composer stamps a Content-ID (<f_…>) on every file it uploads, whatever its type or size, so this hits ordinary mail: a message carrying two small PDFs alongside one large file lists only the large one. Anything sent from web Gmail under 64 KiB — invoices, statements, spreadsheets, screenshots — goes the same way, and nothing in the reader hints that a file is missing.

The paperclip stays on, which makes it worse to diagnose: the flag comes from structure_has_attachment, which tests disposition before falling back to size, and was right all along. The two halves of one rule disagreed. Exempting a declared attachment makes them agree again.

The change

let declared_attachment = part
    .content_disposition()
    .is_some_and(|d| d.is_attachment());
if !declared_attachment
    && part.content_id().is_some()
    && part.contents().len() < INLINE_ATTACHMENT_MIN
{
    continue;
}

Deliberately minimal: the size heuristic keeps working for everything that did not declare itself an attachment.

Decoration still hidden

A cid: logo or a signature image arrives as Content-Disposition: inline, not attachment, so the size test still hides it. The existing tests covering that path are unchanged and still pass:

  • cid_resources_are_not_listed_as_attachments
  • small_cid_image_is_still_only_decoration
  • large_cid_image_is_listed_as_an_attachment

Test

Adds small_declared_attachments_survive_their_content_id: a multipart/mixed in the shape Gmail's composer produces — every part declared attachment and stamped with an <f_…> Content-ID — with two files below the threshold and one above. Before the change it returns one attachment; after, all three.

Full suite: 248 passed, 0 failed.

Note on already-synced mail

attachments_checked remembers messages whose attachments were fetched, including ones that "turned out to have none", so mail already synced by an affected build will not be re-fetched and will keep showing an incomplete list. Clearing that table on upgrade would repair existing mailboxes — happy to add it here or in a follow-up, whichever you prefer.

`extract_attachments` dropped any part carrying a Content-ID and weighing
under 64 KiB, to keep a newsletter's `cid:` logo out of the file list. It
never looked at Content-Disposition, so a part the sender explicitly marked
`attachment` was thrown away on size alone.

Gmail's composer stamps a Content-ID (`<f_…>`) on every file it uploads,
whatever its type or size, so this hits ordinary mail: a message carrying two
small PDFs alongside one large file lists only the large one. Anything sent
from web Gmail under 64 KiB — invoices, statements, spreadsheets,
screenshots — goes the same way, and nothing in the reader hints that a file
is missing.

The paperclip stays on, which makes it worse to diagnose: the flag comes from
`structure_has_attachment`, which tests disposition before falling back to
size, and was right all along. The two halves of one rule disagreed. Exempt a
declared attachment and they agree again.

Decoration is untouched: a `cid:` logo arrives as `disposition: inline`, so
the size test still hides it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@typedev
typedev force-pushed the fix/gmail-inline-cid-attachments branch from 866ad86 to 11da5cc Compare September 2, 2026 17:46
hyprlab added a commit that referenced this pull request Sep 3, 2026
`extract_attachments` dropped any part carrying a Content-ID and weighing
under 64 KiB, to keep a newsletter's `cid:` logo out of the file list. It
never looked at Content-Disposition, so a part the sender explicitly marked
`attachment` was thrown away on size alone.

Gmail's composer stamps a Content-ID (`<f_…>`) on every file it uploads,
whatever its type or size, so this hits ordinary mail: a message carrying two
small PDFs alongside one large file lists only the large one. Anything sent
from web Gmail under 64 KiB — invoices, statements, spreadsheets,
screenshots — goes the same way, and nothing in the reader hints that a file
is missing.

The paperclip stays on, which makes it worse to diagnose: the flag comes from
`structure_has_attachment`, which tests disposition before falling back to
size, and was right all along. The two halves of one rule disagreed. Exempt a
declared attachment and they agree again.

Decoration is untouched: a `cid:` logo arrives as `disposition: inline`, so
the size test still hides it.

Landed from #110.

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
The two previous commits stop new damage; this heals what earlier builds
already wrote. Mail synced before them has attachment lists that are wrong
in place — small declared files missing (#109), blobs stored once per Gmail
label (#111) — and `attachments_checked` remembers those messages as done,
so `queue_attachment_prefetch` would never touch them again and the wrong
lists would survive forever.

Bump the cache schema to v13 and drop `attachments` and
`attachments_checked` on upgrade. The re-fetch is bounded: the prefetch
re-touches only the newest 25 flagged messages per folder, and everything
else heals lazily when a message is opened, since `LoadAttachments` fetches
on demand. Dropping the blobs also reclaims the per-label duplicate copies
in one stroke.

Suggested in #110 and #112.

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
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
…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
@hyprlab
hyprlab commented Sep 4, 2026
Copy link
Copy Markdown
Owner

Landed in stable 1.20.0 as commit b1988c1 on main, with you as co-author. Thank you. Your change went in as written; the only addition alongside it is a one-time attachment cache rebuild on upgrade (schema v13), so mail synced by earlier versions heals too. Closing since the commit is on main rather than merged from the branch.

@hyprlab hyprlab closed this Sep 4, 2026
@typedev
typedev deleted the fix/gmail-inline-cid-attachments branch September 17, 2026 19:32
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
`extract_attachments` dropped any part carrying a Content-ID and weighing
under 64 KiB, to keep a newsletter's `cid:` logo out of the file list. It
never looked at Content-Disposition, so a part the sender explicitly marked
`attachment` was thrown away on size alone.

Gmail's composer stamps a Content-ID (`<f_…>`) on every file it uploads,
whatever its type or size, so this hits ordinary mail: a message carrying two
small PDFs alongside one large file lists only the large one. Anything sent
from web Gmail under 64 KiB — invoices, statements, spreadsheets,
screenshots — goes the same way, and nothing in the reader hints that a file
is missing.

The paperclip stays on, which makes it worse to diagnose: the flag comes from
`structure_has_attachment`, which tests disposition before falling back to
size, and was right all along. The two halves of one rule disagreed. Exempt a
declared attachment and they agree again.

Decoration is untouched: a `cid:` logo arrives as `disposition: inline`, so
the size test still hides it.

Landed from hyprlab#110.

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
The two previous commits stop new damage; this heals what earlier builds
already wrote. Mail synced before them has attachment lists that are wrong
in place — small declared files missing (hyprlab#109), blobs stored once per Gmail
label (hyprlab#111) — and `attachments_checked` remembers those messages as done,
so `queue_attachment_prefetch` would never touch them again and the wrong
lists would survive forever.

Bump the cache schema to v13 and drop `attachments` and
`attachments_checked` on upgrade. The re-fetch is bounded: the prefetch
re-touches only the newest 25 flagged messages per folder, and everything
else heals lazily when a message is opened, since `LoadAttachments` fetches
on demand. Dropping the blobs also reclaims the per-label duplicate copies
in one stroke.

Suggested in hyprlab#110 and hyprlab#112.
somepaulo pushed a commit to somepaulo/hylki that referenced this pull request Sep 24, 2026
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>
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.

Attachments under 64 KiB are dropped when the sender sets a Content-ID (web Gmail)

2 participants

0