aboutsummaryrefslogtreecommitdiffstats
path: root/src/headerField.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-03-15 17:31:26 +0000
committerVincent Richard <[email protected]>2005-03-15 17:31:26 +0000
commit4493a7f801bcbf3dff648b7f89432660ea69c2fd (patch)
treea919e8967bd7cf3a9b4565972fe3d1c59a8cc673 /src/headerField.cpp
parentMore unit tests for 'text' class. (diff)
downloadvmime-4493a7f801bcbf3dff648b7f89432660ea69c2fd.tar.gz
vmime-4493a7f801bcbf3dff648b7f89432660ea69c2fd.zip
Fixed parsing bounds for header fields and values.
Diffstat (limited to 'src/headerField.cpp')
-rw-r--r--src/headerField.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/headerField.cpp b/src/headerField.cpp
index 7c8562da..5fe7a389 100644
--- a/src/headerField.cpp
+++ b/src/headerField.cpp
@@ -134,9 +134,10 @@ headerField* headerField::parseNext(const string& buffer, const string::size_typ
while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
++pos;
- // Extract the field value
- string contents;
+ const string::size_type contentsStart = pos;
+ string::size_type contentsEnd = 0;
+ // Extract the field value
while (pos < end)
{
c = buffer[pos];
@@ -144,18 +145,17 @@ headerField* headerField::parseNext(const string& buffer, const string::size_typ
// Check for end of contents
if (c == '\r' && pos + 1 < end && buffer[pos + 1] == '\n')
{
+ contentsEnd = pos;
pos += 2;
break;
}
else if (c == '\n')
{
+ contentsEnd = pos;
++pos;
break;
}
- const string::size_type ctsStart = pos;
- string::size_type ctsEnd = pos;
-
while (pos < end)
{
c = buffer[pos];
@@ -163,13 +163,13 @@ headerField* headerField::parseNext(const string& buffer, const string::size_typ
// Check for end of line
if (c == '\r' && pos + 1 < end && buffer[pos + 1] == '\n')
{
- ctsEnd = pos;
+ contentsEnd = pos;
pos += 2;
break;
}
else if (c == '\n')
{
- ctsEnd = pos;
+ contentsEnd = pos;
++pos;
break;
}
@@ -177,13 +177,6 @@ headerField* headerField::parseNext(const string& buffer, const string::size_typ
++pos;
}
- if (ctsEnd != ctsStart)
- {
- // Append this line to contents
- contents.append(buffer.begin() + ctsStart,
- buffer.begin() + ctsEnd);
- }
-
// Handle the case of folded lines
if (buffer[pos] == ' ' || buffer[pos] == '\t')
{
@@ -200,7 +193,7 @@ headerField* headerField::parseNext(const string& buffer, const string::size_typ
// Return a new field
headerField* field = headerFieldFactory::getInstance()->create(name);
- field->parse(contents); // TODO: fix incorrect parsed bounds...
+ field->parse(buffer, contentsStart, contentsEnd, NULL);
field->setParsedBounds(nameStart, pos);
if (newPosition)