Continue after multipart error

pull/207/head
M66B 3 years ago
parent e1e268c389
commit 46a9127785

@ -3728,24 +3728,6 @@ class Core {
IMAPStore istore, IMAPFolder ifolder, MimeMessage imessage,
boolean browsed, boolean download,
List<EntityRule> rules, State state, SyncStats stats) throws MessagingException, IOException {
try {
return _synchronizeMessage(context, account, folder,
istore, ifolder, imessage,
browsed, download, rules, state, stats);
} catch (MessageHelper.MessagingStructureException ex) {
Log.e(ex);
long uid = ifolder.getUID(imessage);
EntityOperation.queue(context, folder, EntityOperation.FETCH, uid);
return null;
}
}
private static EntityMessage _synchronizeMessage(
Context context,
EntityAccount account, EntityFolder folder,
IMAPStore istore, IMAPFolder ifolder, MimeMessage imessage,
boolean browsed, boolean download,
List<EntityRule> rules, State state, SyncStats stats) throws MessagingException, IOException {
DB db = DB.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean download_headers = prefs.getBoolean("download_headers", false);

@ -3806,8 +3806,11 @@ public class MessageHelper {
break;
}
}
} else
throw new MessagingStructureException(content, "multipart/mixed");
} else {
String msg = "Expected multipart/mixed got " + content.getClass().getName();
Log.e(msg);
parts.warnings.add(msg);
}
}
if (part.isMimeType("multipart/signed")) {
@ -3851,8 +3854,11 @@ public class MessageHelper {
sb.append(' ').append(i).append('=').append(multipart.getBodyPart(i).getContentType());
Log.e(sb.toString());
}
} else
throw new MessagingStructureException(content, "multipart/signed");
} else {
String msg = "Expected multipart/signed got " + content.getClass().getName();
Log.e(msg);
parts.warnings.add(msg);
}
} else
Log.e(ct.toString());
} else if (part.isMimeType("multipart/encrypted")) {
@ -3873,8 +3879,12 @@ public class MessageHelper {
sb.append(' ').append(i).append('=').append(multipart.getBodyPart(i).getContentType());
Log.e(sb.toString());
}
} else
throw new MessagingStructureException(content, "multipart/encrypted");
} else {
String msg = "Expected multipart/encrypted got " + content.getClass().getName();
Log.e(msg);
parts.warnings.add(msg);
}
} else
Log.e(ct.toString());
} else if (part.isMimeType("application/pkcs7-mime") ||
@ -3954,11 +3964,8 @@ public class MessageHelper {
if (part.isMimeType("multipart/*")) {
Multipart multipart;
Object content = part.getContent(); // Should always be Multipart
if (content instanceof Multipart)
if (content instanceof Multipart) {
multipart = (Multipart) part.getContent();
else
throw new MessagingStructureException(content, "multipart/*");
int count = multipart.getCount();
for (int i = 0; i < count; i++)
try {
@ -3970,7 +3977,14 @@ public class MessageHelper {
Log.w(ex);
parts.warnings.add(Log.formatThrowable(ex, false));
}
return;
} else {
String msg = "Expected multipart/* got " + content.getClass().getName();
Log.e(msg);
parts.warnings.add(msg);
}
}
// https://www.iana.org/assignments/cont-disp/cont-disp.xhtml
String disposition;
try {
@ -4093,7 +4107,6 @@ public class MessageHelper {
parts.attachments.add(apart);
}
}
} catch (FolderClosedException ex) {
throw ex;
} catch (MessagingException ex) {
@ -4435,24 +4448,6 @@ public class MessageHelper {
return values;
}
static class MessagingStructureException extends MessagingException {
private String className;
private String expected;
MessagingStructureException(Object content, String expected) {
super();
if (content != null)
this.className = content.getClass().getName();
this.expected = expected;
}
@Nullable
@Override
public String getMessage() {
return className + " expected: " + expected;
}
}
static class Report {
String type;
String reporter;

Loading…
Cancel
Save