aboutsummaryrefslogtreecommitdiffstats
path: root/tests/net/imap/IMAPParserTest.cpp
diff options
context:
space:
mode:
authorvincent-richard <[email protected]>2020-04-06 16:12:41 +0000
committervincent-richard <[email protected]>2020-04-06 16:12:41 +0000
commit6d90a15bc53f23dfd99bf2d98670134e2c9d3579 (patch)
treefcbc06f0f43794e3427b0a6a80001dfc8c3a0436 /tests/net/imap/IMAPParserTest.cpp
parentAdded support for pipelined and out-of-order replies. (diff)
downloadvmime-6d90a15bc53f23dfd99bf2d98670134e2c9d3579.tar.gz
vmime-6d90a15bc53f23dfd99bf2d98670134e2c9d3579.zip
Map '*' to '\*' in non-strict mode.
Diffstat (limited to 'tests/net/imap/IMAPParserTest.cpp')
-rw-r--r--tests/net/imap/IMAPParserTest.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/net/imap/IMAPParserTest.cpp b/tests/net/imap/IMAPParserTest.cpp
index 232a21dc..303902ae 100644
--- a/tests/net/imap/IMAPParserTest.cpp
+++ b/tests/net/imap/IMAPParserTest.cpp
@@ -37,6 +37,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
VMIME_TEST(testFETCHBodyStructure_NIL_body_fld_param_value)
VMIME_TEST(testFETCHBodyStructure_empty_body_fld_param_instead_of_NIL)
VMIME_TEST(testPipelining)
+ VMIME_TEST(testStarFlagWithoutBackslash)
VMIME_TEST_LIST_END
@@ -304,4 +305,48 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
VASSERT_EQ("a003 resp_cond_state.status", vmime::net::imap::IMAPParser::resp_cond_state::NO, resp3->continue_req_or_response_data[0]->response_data->resp_cond_state->status);
}
+ // Some IMAP servers return "*" instead of "\*" in PERMANENTFLAGS
+ void testStarFlagWithoutBackslash() {
+
+ const char* resp =
+ "* OK [PERMANENTFLAGS (Answered Flagged Deleted Seen Draft *)] Flags permitted.\r\n"
+ "a001 OK Completed.\r\n";
+
+ // Strict mode
+ {
+ auto socket = vmime::make_shared <testSocket>();
+ auto toh = vmime::make_shared <testTimeoutHandler>();
+
+ auto tag = vmime::make_shared <vmime::net::imap::IMAPTag>();
+
+ socket->localSend(resp);
+
+ auto parser = vmime::make_shared <vmime::net::imap::IMAPParser>();
+
+ parser->setSocket(socket);
+ parser->setTimeoutHandler(toh);
+ parser->setStrict(true);
+
+ VASSERT_THROW("strict mode", parser->readResponse(*tag), vmime::exceptions::invalid_response);
+ }
+
+ // Non-strict mode
+ {
+ auto socket = vmime::make_shared <testSocket>();
+ auto toh = vmime::make_shared <testTimeoutHandler>();
+
+ auto tag = vmime::make_shared <vmime::net::imap::IMAPTag>();
+
+ socket->localSend(resp);
+
+ auto parser = vmime::make_shared <vmime::net::imap::IMAPParser>();
+
+ parser->setSocket(socket);
+ parser->setTimeoutHandler(toh);
+ parser->setStrict(false);
+
+ VASSERT_NO_THROW("non-strict mode", parser->readResponse(*tag));
+ }
+ }
+
VMIME_TEST_SUITE_END