MultiPart error handling

pull/193/head
M66B 4 years ago
parent 3d2cb49610
commit d01f038992

@ -31,6 +31,7 @@ import androidx.preference.PreferenceManager;
import com.sun.mail.gimap.GmailMessage; import com.sun.mail.gimap.GmailMessage;
import com.sun.mail.iap.ProtocolException; import com.sun.mail.iap.ProtocolException;
import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.IMAPInputStream;
import com.sun.mail.imap.IMAPMessage; import com.sun.mail.imap.IMAPMessage;
import com.sun.mail.imap.protocol.IMAPProtocol; import com.sun.mail.imap.protocol.IMAPProtocol;
import com.sun.mail.util.ASCIIUtility; import com.sun.mail.util.ASCIIUtility;
@ -2356,13 +2357,17 @@ public class MessageHelper {
if (part.isMimeType("multipart/*")) { if (part.isMimeType("multipart/*")) {
Multipart multipart; Multipart multipart;
Object content = part.getContent(); Object content = part.getContent(); // Should always be Multipart
if (content instanceof Multipart) if (content instanceof Multipart)
multipart = (Multipart) part.getContent(); multipart = (Multipart) part.getContent();
else if (content instanceof String) { else if (content instanceof String) {
String text = (String) content; String text = (String) content;
String sample = text.substring(0, Math.min(200, text.length())); String sample = text.substring(0, Math.min(200, text.length()));
throw new ParseException(content.getClass().getName() + ": " + sample); throw new ParseException(content.getClass().getName() + ": " + sample);
} else if (content instanceof IMAPInputStream) {
String text = Helper.readStream((IMAPInputStream) content);
String sample = text.substring(0, Math.min(200, text.length()));
throw new ParseException(content.getClass().getName() + ": " + sample);
} else } else
throw new ParseException(content.getClass().getName()); throw new ParseException(content.getClass().getName());
@ -2525,7 +2530,10 @@ public class MessageHelper {
} catch (FolderClosedException ex) { } catch (FolderClosedException ex) {
throw ex; throw ex;
} catch (MessagingException ex) { } catch (MessagingException ex) {
Log.w(ex); if (ex instanceof ParseException)
Log.e(ex);
else
Log.w(ex);
parts.warnings.add(Log.formatThrowable(ex, false)); parts.warnings.add(Log.formatThrowable(ex, false));
} }
} }

Loading…
Cancel
Save