message: improve attachment heuristics

Do not consider calender-invitations "attachments"; do mark as
"calendar". Do recognize application/ics as calendar messages.

Update mime-object to expose a message part's disposition.

Change the "is-attachment" heuristic to include inline parts if they
have a filename parameter in their content-disposition.

Note that this doesn't change things radically; the delta is +69 and
-202 for ~6500 attachments.
This commit is contained in:
Dirk-Jan C. Binnema
2026-04-10 20:13:13 +03:00
committed by Seth Ladygo
parent 6715ff418a
commit f353e2dacf
5 changed files with 72 additions and 36 deletions

View File

@ -195,17 +195,22 @@ MessagePart::looks_like_attachment() const noexcept
if (!ctype)
return false; // no content-type: not an attachment.
// we consider some parts _not_ to be attachments regardless of disposition
if (matches(*ctype,{{"application", "pgp-keys"}}))
// we consider some parts _not_ to be attachments regardless of
// disposition
if (matches(*ctype,{{"application", "pgp-keys"},
{"application", "ics"}}))
return false;
// we consider some parts to be attachments regardless of disposition
if (matches(*ctype,{{"image", "*"},
{"audio", "*"},
{"application", "*"},
{"application", "x-patch"}}))
if (is_attachment()) // i.e., as per content-disposition
return true;
// we also consider "inline" parts as attachment, if the
// content-disposition has a filename property.
if (const auto cdisp{mime_object().content_disposition()}; !!cdisp) {
if (const auto& fname{cdisp->parameter("filename")}; !!fname)
return true;
}
// otherwise, rely on the disposition
return is_attachment();
}