Skip to content

v0.9.2 — has:attachment actually matches attachments

Choose a tag to compare

@jr551 jr551 released this 01 Aug 11:36

Fixes webmail #14.

The search UI advertises has:attachment. It was translated to the IMAP keyword $HasAttachment, which Dovecot never sets — so the advertised query returned zero results in every folder, including for messages the list was visibly marking with a paperclip.

"Has an attachment" isn't expressible as an IMAP SEARCH key at all. It's now decided from the message's MIME structure using countAttachments() — the same function that renders the indicator — so the query and the icon cannot disagree.

To keep it cheap, a HEADER Content-Type "multipart/" search narrows server-side first (every message with an attachment is multipart), and the precise pass fetches only bodyStructure for the plausible candidates rather than the whole folder.

Inline-image-only mail stays excluded, and combining tokens (from:bob has:attachment) still applies both.

324 tests, 323 passing, 1 skipped.