aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbmagistro <[email protected]>2017-02-27 16:12:12 +0000
committerbmagistro <[email protected]>2017-02-27 16:12:12 +0000
commit8fb7b007f9cbfbea3f5527d7060557d9b43c9d4a (patch)
tree99d3b62f7ed54a997a5636e2e59a9c336909d707
parentadd option to control parser invalid line behavior (diff)
downloadvmime-8fb7b007f9cbfbea3f5527d7060557d9b43c9d4a.tar.gz
vmime-8fb7b007f9cbfbea3f5527d7060557d9b43c9d4a.zip
use original headerField.cpp to avoid whitespace differences
-rw-r--r--src/vmime/headerField.cpp212
1 files changed, 106 insertions, 106 deletions
diff --git a/src/vmime/headerField.cpp b/src/vmime/headerField.cpp
index 0229668d..dc80957b 100644
--- a/src/vmime/headerField.cpp
+++ b/src/vmime/headerField.cpp
@@ -103,33 +103,33 @@ shared_ptr <headerField> headerField::parseNext
return null;
}
- // This line may be a field description
- if (!parserHelpers::isSpace(c))
- {
- const size_t nameStart = pos; // remember the start position of the line
+ // This line may be a field description
+ if (!parserHelpers::isSpace(c))
+ {
+ const size_t nameStart = pos; // remember the start position of the line
- while (pos < end && (buffer[pos] != ':' && !parserHelpers::isSpace(buffer[pos])))
- ++pos;
+ while (pos < end && (buffer[pos] != ':' && !parserHelpers::isSpace(buffer[pos])))
+ ++pos;
- const size_t nameEnd = pos;
+ const size_t nameEnd = pos;
- while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
+ while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
++pos;
- if (buffer[pos] != ':')
- {
- switch (ctx.getHeaderParseErrorRecoveryMethod()) {
+ if (buffer[pos] != ':')
+ {
+ switch (ctx.getHeaderParseErrorRecoveryMethod()) {
case vmime::headerParseRecoveryMethod::SKIP_LINE:
- // Humm...does not seem to be a valid header line.
- // Skip this error and advance to the next line
- pos = nameStart;
+ // Humm...does not seem to be a valid header line.
+ // Skip this error and advance to the next line
+ pos = nameStart;
- while (pos < end && buffer[pos] != '\n')
- ++pos;
+ while (pos < end && buffer[pos] != '\n')
+ ++pos;
- if (pos < end && buffer[pos] == '\n')
- ++pos;
- break;
+ if (pos < end && buffer[pos] == '\n')
+ ++pos;
+ break;
// case vmime::headerParseRecoveryMethod::APPEND_TO_PREVIOUS_LINE:
// // TODO Implement this...
@@ -139,93 +139,93 @@ shared_ptr <headerField> headerField::parseNext
return null;
break;
}
- }
- else
- {
- // Extract the field name
- const string name(buffer.begin() + nameStart,
- buffer.begin() + nameEnd);
-
- // Skip ':' character
- while (pos < end && buffer[pos] == ':')
- ++pos;
-
- // Skip spaces between ':' and the field contents
- while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
- ++pos;
-
- const size_t contentsStart = pos;
- size_t contentsEnd = 0;
-
- bool firstLine = true;
-
- // Parse field value, taking care of line folding (value on multiple lines)
- for (size_t eol = 0 ; parserHelpers::findEOL(buffer, pos, end, &eol) ; pos = eol)
- {
- // If the line does not start with a folding indicator (SPACE or TAB),
- // and this is not the first line, then stop parsing lines
- if (!firstLine && !(buffer[pos] == ' ' || buffer[pos] == '\t'))
- break;
-
- contentsEnd = eol;
- firstLine = false;
- }
-
- if (pos == end && contentsEnd == 0)
- {
- // End of data, and no CRLF was found at the end
- contentsEnd = end;
- }
-
- // Strip spaces from end of header lines
- while (contentsEnd > contentsStart &&
- (buffer[contentsEnd - 1] == ' ' || buffer[contentsEnd - 1] == '\t' ||
- buffer[contentsEnd - 1] == '\r' || buffer[contentsEnd - 1] == '\n'))
- {
- contentsEnd--;
- }
-
- // Return a new field
- shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(name);
-
- field->parse(ctx, buffer, contentsStart, contentsEnd, NULL);
- field->setParsedBounds(nameStart, pos);
-
- if (newPosition)
- *newPosition = pos;
-
- return (field);
- }
- }
- 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;
-
- if (buffer[pos] == '\n')
- ++pos;
- }
+ }
+ else
+ {
+ // Extract the field name
+ const string name(buffer.begin() + nameStart,
+ buffer.begin() + nameEnd);
+
+ // Skip ':' character
+ while (pos < end && buffer[pos] == ':')
+ ++pos;
+
+ // Skip spaces between ':' and the field contents
+ while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
+ ++pos;
+
+ const size_t contentsStart = pos;
+ size_t contentsEnd = 0;
+
+ bool firstLine = true;
+
+ // Parse field value, taking care of line folding (value on multiple lines)
+ for (size_t eol = 0 ; parserHelpers::findEOL(buffer, pos, end, &eol) ; pos = eol)
+ {
+ // If the line does not start with a folding indicator (SPACE or TAB),
+ // and this is not the first line, then stop parsing lines
+ if (!firstLine && !(buffer[pos] == ' ' || buffer[pos] == '\t'))
+ break;
+
+ contentsEnd = eol;
+ firstLine = false;
+ }
+
+ if (pos == end && contentsEnd == 0)
+ {
+ // End of data, and no CRLF was found at the end
+ contentsEnd = end;
+ }
+
+ // Strip spaces from end of header lines
+ while (contentsEnd > contentsStart &&
+ (buffer[contentsEnd - 1] == ' ' || buffer[contentsEnd - 1] == '\t' ||
+ buffer[contentsEnd - 1] == '\r' || buffer[contentsEnd - 1] == '\n'))
+ {
+ contentsEnd--;
+ }
+
+ // Return a new field
+ shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(name);
+
+ field->parse(ctx, buffer, contentsStart, contentsEnd, NULL);
+ field->setParsedBounds(nameStart, pos);
+
+ if (newPosition)
+ *newPosition = pos;
+
+ return (field);
+ }
+ }
+ 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;
+
+ if (buffer[pos] == '\n')
+ ++pos;
+ }
}
if (newPosition)