From c7a7d832e7149a338495a9c41f43ed100d447fe7 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 11 Jan 2011 03:10:24 +0000 Subject: [PATCH] Better handle the case where a list in an IMAP response is prematurely ended by CRLF. Fixes issue 2852 --- .../fsck/k9/mail/store/ImapResponseParser.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/mail/store/ImapResponseParser.java b/src/com/fsck/k9/mail/store/ImapResponseParser.java index 0b8d1ae9e..e97826e39 100644 --- a/src/com/fsck/k9/mail/store/ImapResponseParser.java +++ b/src/com/fsck/k9/mail/store/ImapResponseParser.java @@ -56,6 +56,7 @@ public class ImapResponseParser { response.mCommandContinuationRequested = parseCommandContinuationRequest(); + //TODO: Add special "resp-text" parsing readTokens(response); } else @@ -89,8 +90,17 @@ public class ImapResponseParser { response.add(token); } + + /* + * TODO: Check for responses ("OK", "PREAUTH", "BYE", "NO", "BAD") + * that can contain resp-text tokens. If found, hand over to a special + * method that parses a resp-text token. There's no need to use + * readToken()/parseToken() on that data. + * + * See RFC 3501, ยง9 Formal Syntax (resp-text) + */ } - response.mCompleted = token == null; + response.mCompleted = (token == null); } /** @@ -204,7 +214,7 @@ public class ImapResponseParser token = parseToken(list); if (token == null) { - break; + return null; } else if (token.equals(")")) { @@ -233,7 +243,7 @@ public class ImapResponseParser token = parseToken(list); if (token == null) { - break; + return null; } else if (token.equals("]")) {