The EML / full-message preview and the print page build their header
as an HTML string. Subject, sender, recipients, date, attachment names
and the attachment link were inserted unescaped, so a crafted header
value became markup in a same-origin page.
DownloadManager.openDownloadedFileWeb loaded pdf.js/pdfobject from a
CDN and put the file name unescaped into a blob page. Nothing calls it.
PreviewEmlFileUtils and PrintUtils escape every text field at the sink.
Callers pass raw strings and no longer pre-escape them. The attachment
link is attribute-escaped and built with Uri, so file names survive the
round-trip. The inline-image alt and id attributes are attribute-escaped.
openDownloadedFileWeb, its CDN loaders and js_interop_stub.dart are
removed, and DownloadManager no longer takes DeviceInfoPlugin.
When a received email contains an inline attachment with a CID but no
matching img[src="cid:..."] in the HTML body, tmail previously hid it
completely — not shown in the body (no img tag) and not in the attachment
panel (isOutsideAttachment returned false due to hasCid+isDispositionInlined).
In GetEmailContentInteractor, extract referenced CIDs from the raw HTML
before transformation, then split allInlineImages into referenced (rendered
in body) and orphaned (no body reference). Orphaned attachments are promoted
to the attachment panel so users can see and download them.
In replaceImageBase64ToImageCID, the early-return path blindly returned
all inline attachments even when none were referenced by a cid: img tag
in the HTML body. This caused orphaned inline blobs (CID present in JMAP
metadata but no body reference) to be silently re-attached on every
reply/forward, propagating malformed MIME structure across the thread.
Fix 1: early-return now checks for actual img[src^="cid:"] body references
before including any attachment — orphaned entries are dropped.
Fix 2: after the base64 loop, scan remaining cid: img tags and include
their attachments so images that failed to download are still forwarded.