Improvement/fix

pull/191/head
M66B 4 years ago
parent 9296b25704
commit e15a7f9d12

@ -1750,24 +1750,15 @@ public class MessageHelper {
return null; 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 // Check character set
String charset = ct.getParameter("charset"); String charset = h.contentType.getParameter("charset");
if (UnknownCharsetProvider.charsetForMime(charset) == null) if (UnknownCharsetProvider.charsetForMime(charset) == null)
warnings.add(context.getString(R.string.title_no_charset, charset)); warnings.add(context.getString(R.string.title_no_charset, charset));
if ((TextUtils.isEmpty(charset) || charset.equalsIgnoreCase(StandardCharsets.US_ASCII.name()))) if ((TextUtils.isEmpty(charset) || charset.equalsIgnoreCase(StandardCharsets.US_ASCII.name())))
charset = null; charset = null;
if (h.part.isMimeType("text/plain")) { if (h.contentType.getBaseType().equalsIgnoreCase("text/plain")) {
Charset cs = null; Charset cs = null;
try { try {
if (charset != null) 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.flow(result);
result = "<div x-plain=\"true\">" + HtmlHelper.formatPre(result) + "</div>"; result = "<div x-plain=\"true\">" + HtmlHelper.formatPre(result) + "</div>";
} else if (h.part.isMimeType("text/html")) { } else if (h.contentType.getBaseType().equalsIgnoreCase("text/html")) {
// Fix incorrect UTF16 // Fix incorrect UTF16
if (charset != null) if (charset != null)
try { try {
@ -1824,7 +1815,7 @@ public class MessageHelper {
for (Element meta : d.select("meta")) { for (Element meta : d.select("meta")) {
if ("Content-Type".equalsIgnoreCase(meta.attr("http-equiv"))) { if ("Content-Type".equalsIgnoreCase(meta.attr("http-equiv"))) {
try { try {
ct = new ContentType(meta.attr("content")); ContentType ct = new ContentType(meta.attr("content"));
charset = ct.getParameter("charset"); charset = ct.getParameter("charset");
} catch (ParseException ex) { } catch (ParseException ex) {
Log.w(ex); Log.w(ex);
@ -1869,8 +1860,8 @@ public class MessageHelper {
} }
} }
} }
} else if (h.part.isMimeType("message/delivery-status") || } else if (h.contentType.getBaseType().equalsIgnoreCase("message/delivery-status") ||
h.part.isMimeType("message/disposition-notification")) { h.contentType.getBaseType().equalsIgnoreCase("message/disposition-notification")) {
StringBuilder report = new StringBuilder(); StringBuilder report = new StringBuilder();
report.append("<hr><div style=\"font-family: monospace; font-size: small;\">"); report.append("<hr><div style=\"font-family: monospace; font-size: small;\">");
for (String line : result.split("\\r?\\n")) { for (String line : result.split("\\r?\\n")) {

Loading…
Cancel
Save