From 668445e9ea351df65d3b1a2e0db210ed846e98da Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 19 Feb 2021 18:22:53 +0100 Subject: [PATCH] Added workaround for seqnum 0 --- app/src/main/java/com/sun/mail/imap/IMAPFolder.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/sun/mail/imap/IMAPFolder.java b/app/src/main/java/com/sun/mail/imap/IMAPFolder.java index ecc2cf22ea..96ec16bb66 100644 --- a/app/src/main/java/com/sun/mail/imap/IMAPFolder.java +++ b/app/src/main/java/com/sun/mail/imap/IMAPFolder.java @@ -4033,6 +4033,12 @@ public class IMAPFolder extends Folder implements UIDFolder, ResponseHandler { * @return the IMAPMessage object */ protected IMAPMessage getMessageBySeqNumber(int seqnum) { + if (seqnum < 1) { + // rfc3501 2.3.1.2: "A relative position from 1 to the number of messages in the mailbox." + // Some servers return sequence number zero when there are no messages (found) + eu.faircode.email.Log.w("Sequence=" + seqnum); + return null; + } if (seqnum > messageCache.size()) { // Microsoft Exchange will sometimes return message // numbers that it has not yet notified the client