From 6565f6dee1d6398c35d3e459324350d035712e85 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 19 Feb 2021 08:39:49 +0100 Subject: [PATCH] Check message ID raw message file --- app/src/main/java/eu/faircode/email/Core.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 32781da620..739e592a8b 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -941,13 +941,17 @@ class Core { // Cross account move if (!file.exists()) throw new IllegalArgumentException("raw message file not found"); - if (TextUtils.isEmpty(message.msgid)) - throw new IllegalArgumentException("Message-ID missing"); Log.i(folder.name + " reading " + file); try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { imessage = new MimeMessage(isession, is); } + + // Check message ID to check raw message file content + MessageHelper helper = new MessageHelper(imessage, context); + String msgid = helper.getMessageID(); + if (TextUtils.isEmpty(message.msgid) || !Objects.equals(message.msgid, msgid)) + throw new IllegalArgumentException("Inconsistent msgid=" + message.msgid + "/" + msgid); } db.message().setMessageRaw(message.id, true);