From 194045c92ce1bc49b4cdf33edaa4a22c370d457b Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 1 Jun 2019 18:59:56 +0200 Subject: [PATCH] Prevent cast exception --- .../main/java/eu/faircode/email/MessageHelper.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 8795fd346f..10d325796d 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -971,7 +971,16 @@ public class MessageHelper { private void getMessageParts(Part part, MessageParts parts, boolean pgp) throws IOException, FolderClosedException { try { if (part.isMimeType("multipart/*")) { - Multipart multipart = (Multipart) part.getContent(); + Multipart multipart; + final Object content = part.getContent(); + if (content instanceof Multipart) + multipart = (Multipart) part.getContent(); + else { + String text = (String) content; + String sample = text.substring(0, Math.min(80, text.length())); + throw new ParseException(content.getClass().getName() + ": " + sample); + } + for (int i = 0; i < multipart.getCount(); i++) try { Part cpart = multipart.getBodyPart(i);