From d3d19823439fcdb9dc51e73d03923e482724dd4b Mon Sep 17 00:00:00 2001 From: "fengzhihao.infeng" Date: Tue, 31 Mar 2026 22:11:15 +0800 Subject: [PATCH] fix(mail): use consistent inline predicate and safer HTML part lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. removeOrphanedInlineParts: change condition from ContentDisposition=="inline" && ContentID!="" to isInlinePart(child) && ContentID!="", matching the predicate used elsewhere — parts with only a ContentID (no Content-Disposition) are now correctly cleaned up. 2. postProcessInlineImages: use findPrimaryBodyPart instead of findPart(snapshot.Body, PrimaryHTMLPartID) to avoid stale PartID after ops restructure the MIME tree. --- shortcuts/mail/draft/patch.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shortcuts/mail/draft/patch.go b/shortcuts/mail/draft/patch.go index f6941f0c2..4307e6678 100644 --- a/shortcuts/mail/draft/patch.go +++ b/shortcuts/mail/draft/patch.go @@ -966,7 +966,7 @@ func removeOrphanedInlineParts(root *Part, referencedCIDs map[string]bool) { if child == nil { continue } - if strings.EqualFold(child.ContentDisposition, "inline") && child.ContentID != "" { + if isInlinePart(child) && child.ContentID != "" { if !referencedCIDs[strings.ToLower(child.ContentID)] { root.Dirty = true continue @@ -982,7 +982,7 @@ func removeOrphanedInlineParts(root *Part, referencedCIDs map[string]bool) { // 2. Validates all CID references in HTML resolve to MIME parts. // 3. Removes orphaned inline MIME parts no longer referenced by HTML. func postProcessInlineImages(snapshot *DraftSnapshot) error { - htmlPart := findPart(snapshot.Body, snapshot.PrimaryHTMLPartID) + htmlPart := findPrimaryBodyPart(snapshot.Body, "text/html") if htmlPart == nil { return nil }