Fixed handling missing content types

pull/162/head
M66B 5 years ago
parent 500b5eeacc
commit fd8613a89a

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

Loading…
Cancel
Save