Fixed parsing bounds for header fields and values.

This commit is contained in:
Vincent Richard 2005-03-15 17:31:26 +00:00
parent e0aabf8c72
commit 4493a7f801
3 changed files with 12 additions and 15 deletions

View File

@ -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&)

View File

@ -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)

View File

@ -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)