From a8cf904f7f766bf92dac5c91d4a67bc13e794823 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 22 Nov 2019 14:07:44 +0100 Subject: [PATCH] Fix attachment disposition --- .../java/eu/faircode/email/FragmentCompose.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 1df0612c22..b6be86be7f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -2532,15 +2532,27 @@ public class FragmentCompose extends FragmentBase { } else if (ref != null && ("reply".equals(action) || "reply_all".equals(action) || "forward".equals(action) || "editasnew".equals(action))) { + + List cid = new ArrayList<>(); + for (Element img : document.select("img")) { + String src = img.attr("src"); + if (src.startsWith("cid:")) + cid.add("<" + src.substring(4) + ">"); + } + int sequence = 0; List attachments = db.attachment().getAttachments(ref.id); for (EntityAttachment attachment : attachments) if (attachment.encryption == null && ("forward".equals(action) || "editasnew".equals(action) || - (attachment.isInline() && attachment.isImage()))) { + (cid.contains(attachment.cid) || + (attachment.isInline() && attachment.isImage())))) { if (attachment.available) { File source = attachment.getFile(context); + if (cid.contains(attachment.cid)) + attachment.disposition = Part.INLINE; + attachment.id = null; attachment.message = data.draft.id; attachment.sequence = ++sequence;