aboutsummaryrefslogtreecommitdiffstats
path: root/tests/parser/bodyPartTest.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2008-07-11 20:45:17 +0000
committerVincent Richard <[email protected]>2008-07-11 20:45:17 +0000
commita68e12235430901f71982ad2593268f38ea4b85b (patch)
tree46494db4846a38e837f01ff3ca52081e90e65e24 /tests/parser/bodyPartTest.cpp
parentFixed extra space in subject (see https://sourceforge.net/forum/message.php?m... (diff)
downloadvmime-a68e12235430901f71982ad2593268f38ea4b85b.tar.gz
vmime-a68e12235430901f71982ad2593268f38ea4b85b.zip
Recover from broken emails without a final boundary (Zarafa).
Diffstat (limited to 'tests/parser/bodyPartTest.cpp')
-rw-r--r--tests/parser/bodyPartTest.cpp28
1 files changed, 28 insertions, 0 deletions
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 <const vmime::contentHandler> 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;