From a68e12235430901f71982ad2593268f38ea4b85b Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Fri, 11 Jul 2008 20:45:17 +0000 Subject: Recover from broken emails without a final boundary (Zarafa). --- tests/parser/bodyPartTest.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/parser/bodyPartTest.cpp') diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp index 31c18879..d6fff5e8 100644 --- a/tests/parser/bodyPartTest.cpp +++ b/tests/parser/bodyPartTest.cpp @@ -33,6 +33,7 @@ VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST(testGenerate) + VMIME_TEST(testParseMissingLastBoundary) VMIME_TEST_LIST_END @@ -43,6 +44,16 @@ VMIME_TEST_SUITE_BEGIN buffer.begin() + c.getParsedOffset() + c.getParsedLength()); } + static const vmime::string extractContents(const vmime::ref cts) + { + std::ostringstream oss; + vmime::utility::outputStreamAdapter os(oss); + + cts->extract(os); + + return oss.str(); + } + void testParse() { @@ -68,6 +79,23 @@ VMIME_TEST_SUITE_BEGIN VASSERT_EQ("6", "BODY", extractComponentString(str3, *p3.getBody())); } + void testParseMissingLastBoundary() + { + vmime::string str = + "Content-Type: multipart/mixed; boundary=\"MY-BOUNDARY\"" + "\r\n\r\n" + "--MY-BOUNDARY\r\nHEADER1\r\n\r\nBODY1" + "--MY-BOUNDARY\r\nHEADER2\r\n\r\nBODY2"; + + vmime::bodyPart p; + p.parse(str); + + VASSERT_EQ("count", 2, p.getBody()->getPartCount()); + + VASSERT_EQ("part1-body", "BODY1", extractContents(p.getBody()->getPartAt(0)->getBody()->getContents())); + VASSERT_EQ("part2-body", "BODY2", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents())); + } + void testGenerate() { vmime::bodyPart p1; -- cgit v1.2.3