aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2006-12-05 19:36:57 +0000
committerVincent Richard <[email protected]>2006-12-05 19:36:57 +0000
commit58594efcd8a2b5ac77fc0050b4ff351db86aa0a6 (patch)
tree4f7a9af7a6f961d5ec2a9459acf5fcaed89feb86
parentCheck for space/tab instead of using isspace(). (diff)
downloadvmime-58594efcd8a2b5ac77fc0050b4ff351db86aa0a6.tar.gz
vmime-58594efcd8a2b5ac77fc0050b4ff351db86aa0a6.zip
Allow a line containing only spaces as header separator.
-rw-r--r--src/headerField.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/headerField.cpp b/src/headerField.cpp
index dedacff4..0aae89f6 100644
--- a/src/headerField.cpp
+++ b/src/headerField.cpp
@@ -186,6 +186,18 @@ ref <headerField> headerField::parseNext(const string& buffer, const string::siz
{
// This is a folding white-space: we keep it as is and
// we continue with contents parsing...
+
+ // If the line contains only space characters, we assume it is
+ // the end of the headers. This is not strictly standard-compliant
+ // but, hey, we can't fail when parsing some malformed mails...
+ while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
+ ++pos;
+
+ if ((pos < end && buffer[pos] == '\n') ||
+ (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] == '\n'))
+ {
+ break;
+ }
}
else
{
@@ -208,6 +220,26 @@ ref <headerField> headerField::parseNext(const string& buffer, const string::siz
}
else
{
+ // If the line contains only space characters, we assume it is
+ // the end of the headers.
+ while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
+ ++pos;
+
+ if (pos < end && buffer[pos] == '\n')
+ {
+ if (newPosition)
+ *newPosition = pos + 1; // LF: illegal
+
+ return NULL;
+ }
+ else if (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] == '\n')
+ {
+ if (newPosition)
+ *newPosition = pos + 2; // CR+LF
+
+ return NULL;
+ }
+
// Skip this error and advance to the next line
while (pos < end && buffer[pos] != '\n')
++pos;