diff options
| author | Vincent Richard <[email protected]> | 2019-10-07 10:50:30 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-10-07 10:50:30 +0200 |
| commit | ab340b561d8012c2837c92abdf273a678921c3b7 (patch) | |
| tree | 8bf4749284a3d6cece5aa00bb84ce5744afb1e0e /tests/parser | |
| parent | Merge pull request #225 from 0xd34df00d/patch-1 (diff) | |
| parent | Skip delimiter lines that are not exactly equal to the boundary (diff) | |
| download | vmime-ab340b561d8012c2837c92abdf273a678921c3b7.tar.gz vmime-ab340b561d8012c2837c92abdf273a678921c3b7.zip | |
Merge pull request #227 from Kopano-dev/boundaryprefix
Boundary marker parsing: WS rules and EQ check
Diffstat (limited to 'tests/parser')
| -rw-r--r-- | tests/parser/bodyPartTest.cpp | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp index 91742553..3aaadd03 100644 --- a/tests/parser/bodyPartTest.cpp +++ b/tests/parser/bodyPartTest.cpp @@ -39,6 +39,7 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) VMIME_TEST(testGenerate7bit) VMIME_TEST(testTextUsageForQPEncoding) VMIME_TEST(testParseVeryBigMessage) + VMIME_TEST(testParseBoundaryPrefix) VMIME_TEST_LIST_END @@ -213,9 +214,9 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) 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 \t \r\nHEADER1\r\n\r\nBODY1\r\n" "--MY-BOUNDARY\r\n" - "-- MY-BOUNDARY--\r\n"; + "--MY-BOUNDARY-- \r\n"; vmime::bodyPart p; p.parse(str); @@ -291,7 +292,7 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) vmime::string str = "Content-Type: multipart/mixed" "\r\n\r\n" - "-- \t UNKNOWN-BOUNDARY\r\nHEADER1\r\n\r\nBODY1\r\n" + "--UNKNOWN-BOUNDARY \t \r\nHEADER1\r\n\r\nBODY1\r\n" "--UNKNOWN-BOUNDARY\r\nHEADER2\r\n\r\nBODY2\r\n" "--UNKNOWN-BOUNDARY--"; @@ -373,4 +374,41 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) VASSERT("2.2", vmime::dynamicCast <const vmime::streamContentHandler>(body2Cts) != NULL); } + void testParseBoundaryPrefix() { + /* + * Clients are not supposed to create boundary identifiers that + * contain a prefix of another (RFC 2046 section 5.1), but alas + * CANCOM FortiMail produces this garbage. + */ + vmime::string str = + "Content-Type: multipart/related; boundary=\"--b12\"\r\n" + "\r\n" + "----b12\r\n" + "Content-Type: multipart/alternative; boundary=\"--b12-1\"\r\n" + "\r\n" + "----b12-1\r\n" + "Content-Type: text/plain; charset=utf-8\r\n" + "\r\n" + "P11\r\n" + "----b12-1\r\n" + "Content-Type: text/html; charset=utf-8\r\n" + "\r\n" + "P12\r\n" + "----b12-1--\r\n" + "----b12\r\n" + "\r\n" + "P2\r\n" + "----b12--\r\n"; + + vmime::bodyPart relco; + relco.parse(str); + auto relbd = relco.getBody(); + VASSERT_EQ("global-partcount", 2, relbd->getPartCount()); + auto altbd = relbd->getPartAt(0)->getBody(); + VASSERT_EQ("part1-partcount", 2, altbd->getPartCount()); + VASSERT_EQ("part1.1-body", "P11", extractContents(altbd->getPartAt(0)->getBody()->getContents())); + VASSERT_EQ("part1.2-body", "P12", extractContents(altbd->getPartAt(1)->getBody()->getContents())); + VASSERT_EQ("part2-body", "P2", extractContents(relbd->getPartAt(1)->getBody()->getContents())); + } + VMIME_TEST_SUITE_END |
