From e15a7f9d122e894481a7ef4f0f6554868162eae2 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 9 Jan 2021 19:40:53 +0100 Subject: [PATCH] Improvement/fix --- .../java/eu/faircode/email/MessageHelper.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index f10f9e26ed..866a2d30f7 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1750,24 +1750,15 @@ public class MessageHelper { return null; } - // Get content type - ContentType ct; - try { - ct = new ContentType(h.part.getContentType()); - } catch (ParseException ex) { - Log.e(ex); - ct = new ContentType(); - } - // Check character set - String charset = ct.getParameter("charset"); + String charset = h.contentType.getParameter("charset"); if (UnknownCharsetProvider.charsetForMime(charset) == null) warnings.add(context.getString(R.string.title_no_charset, charset)); if ((TextUtils.isEmpty(charset) || charset.equalsIgnoreCase(StandardCharsets.US_ASCII.name()))) charset = null; - if (h.part.isMimeType("text/plain")) { + if (h.contentType.getBaseType().equalsIgnoreCase("text/plain")) { Charset cs = null; try { if (charset != null) @@ -1794,10 +1785,10 @@ public class MessageHelper { } } - if ("flowed".equalsIgnoreCase(ct.getParameter("format"))) + if ("flowed".equalsIgnoreCase(h.contentType.getParameter("format"))) result = HtmlHelper.flow(result); result = "
" + HtmlHelper.formatPre(result) + "
"; - } else if (h.part.isMimeType("text/html")) { + } else if (h.contentType.getBaseType().equalsIgnoreCase("text/html")) { // Fix incorrect UTF16 if (charset != null) try { @@ -1824,7 +1815,7 @@ public class MessageHelper { for (Element meta : d.select("meta")) { if ("Content-Type".equalsIgnoreCase(meta.attr("http-equiv"))) { try { - ct = new ContentType(meta.attr("content")); + ContentType ct = new ContentType(meta.attr("content")); charset = ct.getParameter("charset"); } catch (ParseException ex) { Log.w(ex); @@ -1869,8 +1860,8 @@ public class MessageHelper { } } } - } else if (h.part.isMimeType("message/delivery-status") || - h.part.isMimeType("message/disposition-notification")) { + } else if (h.contentType.getBaseType().equalsIgnoreCase("message/delivery-status") || + h.contentType.getBaseType().equalsIgnoreCase("message/disposition-notification")) { StringBuilder report = new StringBuilder(); report.append("
"); for (String line : result.split("\\r?\\n")) {