Check message ID raw message file

This commit is contained in:
M66B 2021-02-19 08:39:49 +01:00
parent af1aabf004
commit 6565f6dee1
1 changed files with 6 additions and 2 deletions

View File

@ -941,13 +941,17 @@ class Core {
// Cross account move // Cross account move
if (!file.exists()) if (!file.exists())
throw new IllegalArgumentException("raw message file not found"); 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); Log.i(folder.name + " reading " + file);
try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { try (InputStream is = new BufferedInputStream(new FileInputStream(file))) {
imessage = new MimeMessage(isession, is); 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); db.message().setMessageRaw(message.id, true);