mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 07:01:05 +00:00
Workaround inconsistent message content type
This commit is contained in:
parent
e73e77e471
commit
b066c06813
2 changed files with 20 additions and 16 deletions
|
@ -573,6 +573,26 @@ public class IMAPMessage extends MimeMessage implements ReadableMime {
|
||||||
// If we haven't cached the type yet ..
|
// If we haven't cached the type yet ..
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
loadBODYSTRUCTURE();
|
loadBODYSTRUCTURE();
|
||||||
|
|
||||||
|
// Some servers report incorrectly text/plain in some situations
|
||||||
|
if ("text".equalsIgnoreCase(bs.type) &&
|
||||||
|
"plain".equalsIgnoreCase(bs.subtype))
|
||||||
|
try {
|
||||||
|
String[] c = getHeader("Content-type");
|
||||||
|
if (c != null && c.length == 1) {
|
||||||
|
ContentType ct = new ContentType(c[0]);
|
||||||
|
if (!bs.type.equalsIgnoreCase(ct.getPrimaryType()) ||
|
||||||
|
!bs.subtype.equalsIgnoreCase(ct.getSubType())) {
|
||||||
|
eu.faircode.email.Log.e("Inconsistent" +
|
||||||
|
" bs=" + bs.type + "/" + bs.subtype + "/" + bs.cParams + " header=" + ct);
|
||||||
|
type = ct.toString();
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (MessagingException ex) {
|
||||||
|
eu.faircode.email.Log.e(ex);
|
||||||
|
}
|
||||||
|
|
||||||
// generate content-type from BODYSTRUCTURE
|
// generate content-type from BODYSTRUCTURE
|
||||||
ContentType ct = new ContentType(bs.type, bs.subtype, bs.cParams);
|
ContentType ct = new ContentType(bs.type, bs.subtype, bs.cParams);
|
||||||
type = ct.toString();
|
type = ct.toString();
|
||||||
|
|
|
@ -2545,22 +2545,6 @@ public class MessageHelper {
|
||||||
try {
|
try {
|
||||||
// From the body structure
|
// From the body structure
|
||||||
contentType = new ContentType(part.getContentType());
|
contentType = new ContentType(part.getContentType());
|
||||||
|
|
||||||
// Workaround bodystructure not matching header
|
|
||||||
if (part instanceof MimeMessage &&
|
|
||||||
"text/plain".equalsIgnoreCase(contentType.getBaseType()))
|
|
||||||
try {
|
|
||||||
String[] c = part.getHeader("Content-type");
|
|
||||||
if (c != null && c.length > 0) {
|
|
||||||
ContentType ct = new ContentType(c[0]);
|
|
||||||
if ("text/html".equalsIgnoreCase(ct.getBaseType())) {
|
|
||||||
Log.e("Inconsistent bs=" + contentType + " header=" + ct);
|
|
||||||
contentType = ct;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (MessagingException ex) {
|
|
||||||
Log.w(ex);
|
|
||||||
}
|
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ex) {
|
||||||
if (part instanceof MimeMessage)
|
if (part instanceof MimeMessage)
|
||||||
Log.w("MimeMessage content type=" + ex.getMessage());
|
Log.w("MimeMessage content type=" + ex.getMessage());
|
||||||
|
|
Loading…
Reference in a new issue