Improvement/fix

This commit is contained in:
M66B 2021-01-09 19:40:53 +01:00
parent 9296b25704
commit e15a7f9d12
1 changed files with 7 additions and 16 deletions

View File

@ -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 = "<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
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("<hr><div style=\"font-family: monospace; font-size: small;\">");
for (String line : result.split("\\r?\\n")) {