From 2acd55a9ef9a7b409010588825c064a86b198c9e Mon Sep 17 00:00:00 2001 From: cketti Date: Sun, 17 Jul 2011 14:37:21 +0200 Subject: [PATCH] Implemented work-around to handle malformed UIDL responses (POP3). Fixes issue 3546 --- src/com/fsck/k9/mail/store/Pop3Store.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index 420878874..3f4319206 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -456,7 +456,22 @@ public class Pop3Store extends Store { if (response.equals(".")) { break; } - String[] uidParts = response.split(" "); + + /* + * Yet another work-around for buggy server software: + * Replace every occurence of multiple spaces with exactly one space. This way + * the String.split() call below will have the desired effect, i.e. split the + * response into message number and unique identifier. + * + * Example for a malformed response: + * 1 2011071307115510400ae3e9e00bmu9 + * + * Note the three spaces between message number and unique identifier. + * See issue 3546 + */ + String cleanedResponse = response.replaceAll(" +", " "); + + String[] uidParts = cleanedResponse.split(" "); if ((uidParts.length >= 3) && "+OK".equals(uidParts[0])) { /* * At least one server software places a "+OK" in