diff --git a/tests/net/imap/IMAPParserTest.cpp b/tests/net/imap/IMAPParserTest.cpp index 30e8f574..e598a548 100644 --- a/tests/net/imap/IMAPParserTest.cpp +++ b/tests/net/imap/IMAPParserTest.cpp @@ -31,6 +31,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest) VMIME_TEST_LIST_BEGIN VMIME_TEST(testExtraSpaceInCapaResponse) + VMIME_TEST(testContinueReqWithoutSpace) VMIME_TEST_LIST_END @@ -64,4 +65,40 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest) VASSERT_THROW("strict mode", parser->readResponse(/* literalHandler */ NULL), vmime::exceptions::invalid_response); } + // For Apple iCloud/Exchange IMAP server + void testContinueReqWithoutSpace() + { + // continue_req ::= "+" SPACE (resp_text / base64) + // + // Some servers do not send SPACE when response text is empty. + // IMAP parser should allow this in non-strict mode. + // + // Eg: + // + // C: a002 AUTHENTICATE xxx[CR][LF] + // S: +[CR][LF] + + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); + + vmime::shared_ptr tag = + vmime::make_shared (); + + socket->localSend("+\r\n"); + + vmime::shared_ptr parser = + vmime::make_shared + (tag, vmime::dynamicCast (socket), toh); + + parser->setStrict(false); + VASSERT_NO_THROW("non-strict mode", parser->readResponse()); + + ++(*tag); + + socket->localSend("+\r\n"); + + parser->setStrict(true); + VASSERT_THROW("strict mode", parser->readResponse(), vmime::exceptions::invalid_response); + } + VMIME_TEST_SUITE_END