1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 18:27:43 +00:00

Workaround protocol parameter missing

This commit is contained in:
M66B 2020-07-10 17:26:07 +02:00
parent 19906af1ff
commit aa423271d0

View file

@ -2145,9 +2145,32 @@ public class MessageHelper {
try {
if (imessage instanceof IMAPMessage) {
if (body)
imessage.getContentType(); // force loadBODYSTRUCTURE
else
if (body) {
String contentType = imessage.getContentType(); // force loadBODYSTRUCTURE
// Workaround protocol parameter missing
// Happens with Yandex and possibly other providers
boolean load = false;
try {
ContentType ct = new ContentType(contentType);
if (ct.match("multipart/signed") || ct.match("multipart/encrypted")) {
String protocol = ct.getParameter("protocol");
if (protocol == null)
load = true;
} else if (ct.match("application/pkcs7-mime") || ct.match("application/x-pkcs7-mime")) {
String smimeType = ct.getParameter("smime-type");
if (smimeType == null)
load = true;
}
} catch (Throwable ex) {
Log.w(ex);
}
if (load) {
Log.w("Protocol missing content-type=" + contentType);
throw new MessagingException("Failed to load IMAP envelope");
}
} else
imessage.getMessageID(); // force loadEnvelope
}
} catch (MessagingException ex) {