diff --git a/src/java/davmail/imap/ImapConnection.java b/src/java/davmail/imap/ImapConnection.java index e677c315..9d3ecc77 100644 --- a/src/java/davmail/imap/ImapConnection.java +++ b/src/java/davmail/imap/ImapConnection.java @@ -678,7 +678,7 @@ public class ImapConnection extends AbstractConnection { // get full param if (param.indexOf('[') >= 0) { StringBuilder paramBuffer = new StringBuilder(param); - while (paramTokens.hasMoreTokens() && param.indexOf(']') < 0) { + while (paramTokens.hasMoreTokens() && paramBuffer.indexOf("]") < 0) { paramBuffer.append(' ').append(paramTokens.nextToken()); } param = paramBuffer.toString(); diff --git a/src/test/davmail/imap/TestImap.java b/src/test/davmail/imap/TestImap.java index 2f9924b8..c6364832 100644 --- a/src/test/davmail/imap/TestImap.java +++ b/src/test/davmail/imap/TestImap.java @@ -289,6 +289,11 @@ public class TestImap extends AbstractDavMailTestCase { assertEquals(". OK UID FETCH completed", readFullAnswer(".")); } + public void testHeaderBodyFetch() throws IOException { + writeLine(". UID FETCH " + messageUid + " (UID BODY.PEEK[HEADER.FIELDS (Content-Type Content-Transfer-Encoding)] BODY.PEEK[TEXT]<0.2048>)"); + assertEquals(". OK UID FETCH completed", readFullAnswer(".")); + } + public void testFetchInternalDate() throws IOException { writeLine(". UID FETCH " + messageUid + " (INTERNALDATE)"); assertEquals(". OK UID FETCH completed", readFullAnswer("."));