aboutsummaryrefslogtreecommitdiffstats
path: root/tests/parser/bodyPartTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/parser/bodyPartTest.cpp')
-rw-r--r--tests/parser/bodyPartTest.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
index 487b3160..453982e0 100644
--- a/tests/parser/bodyPartTest.cpp
+++ b/tests/parser/bodyPartTest.cpp
@@ -30,10 +30,12 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VMIME_TEST(testParse)
VMIME_TEST(testGenerate)
VMIME_TEST(testParseGuessBoundary)
+ VMIME_TEST(testParseGuessBoundaryWithTransportPadding)
VMIME_TEST(testParseMissingLastBoundary)
VMIME_TEST(testPrologEpilog)
VMIME_TEST(testPrologEncoding)
VMIME_TEST(testSuccessiveBoundaries)
+ VMIME_TEST(testTransportPaddingInBoundary)
VMIME_TEST(testGenerate7bit)
VMIME_TEST(testTextUsageForQPEncoding)
VMIME_TEST(testParseVeryBigMessage)
@@ -200,6 +202,24 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("part2-body", "", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
}
+ void testTransportPaddingInBoundary()
+ {
+ vmime::string str =
+ "Content-Type: multipart/mixed; boundary=\"MY-BOUNDARY\""
+ "\r\n\r\n"
+ "-- \t MY-BOUNDARY\r\nHEADER1\r\n\r\nBODY1\r\n"
+ "--MY-BOUNDARY\r\n"
+ "-- MY-BOUNDARY--\r\n";
+
+ 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", "", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
+ }
+
/** Ensure '7bit' encoding is used when body is 7-bit only. */
void testGenerate7bit()
{
@@ -256,6 +276,28 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("part2-body", "BODY2", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
}
+ void testParseGuessBoundaryWithTransportPadding()
+ {
+ // Boundary is not specified in "Content-Type" field
+ // Parser will try to guess it from message contents.
+ // Transport padding white spaces should be ignored.
+
+ vmime::string str =
+ "Content-Type: multipart/mixed"
+ "\r\n\r\n"
+ "-- \t UNKNOWN-BOUNDARY\r\nHEADER1\r\n\r\nBODY1\r\n"
+ "--UNKNOWN-BOUNDARY\r\nHEADER2\r\n\r\nBODY2\r\n"
+ "--UNKNOWN-BOUNDARY--";
+
+ 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 testParseVeryBigMessage()
{
// When parsing from a seekable input stream, body contents should not