aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Engelhardt <[email protected]>2019-10-05 09:24:48 +0000
committerJan Engelhardt <[email protected]>2019-10-05 09:37:09 +0000
commitb06e9e6f86389864854ece1207cd30cfe6a874a2 (patch)
tree8bf4749284a3d6cece5aa00bb84ce5744afb1e0e /src
parentDisregard whitespace between leading boundary hyphens and marker (diff)
downloadvmime-b06e9e6f86389864854ece1207cd30cfe6a874a2.tar.gz
vmime-b06e9e6f86389864854ece1207cd30cfe6a874a2.zip
Skip delimiter lines that are not exactly equal to the boundary
There is crap software out there that generates mails violating the prefix ban clause from RFC 2046 §5.1 ¶2. Switch vmime from a prefix match to an equality match, similar to what Alpine and Thunderbird do too.
Diffstat (limited to 'src')
-rw-r--r--src/vmime/body.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vmime/body.cpp b/src/vmime/body.cpp
index 4103f328..a3875b9d 100644
--- a/src/vmime/body.cpp
+++ b/src/vmime/body.cpp
@@ -53,6 +53,11 @@ body::~body() {
}
+/*
+ * boundaryStart: will become the index for "\r\n--marker"
+ * boundaryEnd: will become the index after "marker", i.e. index for potential trailing "--", "\r\n", etc.
+ * return value: index for "marker"
+ */
// static
size_t body::findNextBoundaryPosition(
const shared_ptr <utility::parserInputStreamAdapter>& parser,
@@ -271,6 +276,19 @@ void body::parseImpl(
boundaryEnd += 2;
} else if (boundaryEnd < end && parser->peekByte() == '\n') {
++boundaryEnd;
+ } else if (boundaryEnd == end) {
+ } else {
+ /*
+ * RFC 2046 §5.1.1 page 19: """[...] optional
+ * linear whitespace, and a terminating
+ * CRLF.""" — junk handling is left
+ * unspecified, so we might as well skip it to
+ * facilitate broken mails.
+ */
+ boundaryEnd += parser->skipIf([](char_t c) { return c != '\n'; }, end);
+ pos = findNextBoundaryPosition(parser, boundary, boundaryEnd, end, &boundaryStart, &boundaryEnd);
+ --index;
+ continue;
}
if (index == 0) {