Workaround wrong server content type

pull/162/head
M66B 6 years ago
parent f3645ec4d5
commit 592ba34c74

@ -1023,7 +1023,7 @@ public class MessageHelper {
// Prevent Jsoup throwing an exception // Prevent Jsoup throwing an exception
result = result.replace("\0", ""); result = result.replace("\0", "");
if (part.isMimeType("text/plain")) { if (plain != null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<span>"); sb.append("<span>");
@ -1292,17 +1292,24 @@ public class MessageHelper {
filename = null; filename = null;
} }
ContentType contentType = new ContentType(part.getContentType());
if (part instanceof MimeMessage) {
String header = ((MimeMessage) part).getHeader("Content-Type", null);
ContentType ct = new ContentType(header);
if (!ct.getBaseType().equalsIgnoreCase(contentType.getBaseType())) {
Log.w("Content type message=" + ct + " part=" + contentType);
contentType = ct;
}
}
if (!Part.ATTACHMENT.equalsIgnoreCase(disposition) && if (!Part.ATTACHMENT.equalsIgnoreCase(disposition) &&
TextUtils.isEmpty(filename) && TextUtils.isEmpty(filename) &&
((parts.plain == null && part.isMimeType("text/plain")) || ((parts.plain == null && "text/plain".equalsIgnoreCase(contentType.getBaseType())) ||
(parts.html == null && part.isMimeType("text/html")))) { (parts.html == null && "text/html".equalsIgnoreCase(contentType.getBaseType())))) {
if (part.isMimeType("text/plain")) { if ("text/plain".equalsIgnoreCase(contentType.getBaseType()))
if (parts.plain == null)
parts.plain = part; parts.plain = part;
} else { else
if (parts.html == null)
parts.html = part; parts.html = part;
}
} else { } else {
AttachmentPart apart = new AttachmentPart(); AttachmentPart apart = new AttachmentPart();
apart.disposition = disposition; apart.disposition = disposition;

Loading…
Cancel
Save