aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/address.cpp2
-rw-r--r--src/headerField.cpp23
-rw-r--r--src/mailboxField.cpp2
3 files changed, 12 insertions, 15 deletions
diff --git a/src/address.cpp b/src/address.cpp
index 14786d54..cf13a007 100644
--- a/src/address.cpp
+++ b/src/address.cpp
@@ -178,6 +178,8 @@ address* address::parseNext(const string& buffer, const string::size_type positi
try
{
parsedAddress->parse(buffer, start, pos, NULL);
+ parsedAddress->setParsedBounds(start, pos);
+
return (parsedAddress);
}
catch (std::exception&)
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)
diff --git a/src/mailboxField.cpp b/src/mailboxField.cpp
index 3fe023c0..af220c50 100644
--- a/src/mailboxField.cpp
+++ b/src/mailboxField.cpp
@@ -66,6 +66,8 @@ void mailboxField::parse(const string& buffer, const string::size_type position,
delete (parsedAddress);
+ getValue().setParsedBounds(position, end);
+
setParsedBounds(position, end);
if (newPosition)