Strip spaces at end of header lines (Zarafa).
This commit is contained in:
parent
21945be4c4
commit
32eb1ebe34
@ -142,7 +142,7 @@ ref <headerField> headerField::parseNext
|
|||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
const string::size_type contentsStart = pos;
|
const string::size_type contentsStart = pos;
|
||||||
string::size_type contentsEnd = end;
|
string::size_type contentsEnd = 0;
|
||||||
|
|
||||||
// Extract the field value
|
// Extract the field value
|
||||||
while (pos < end)
|
while (pos < end)
|
||||||
@ -215,6 +215,20 @@ ref <headerField> headerField::parseNext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// Return a new field
|
||||||
ref <headerField> field = headerFieldFactory::getInstance()->create(name);
|
ref <headerField> field = headerFieldFactory::getInstance()->create(name);
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
|
|||||||
VMIME_TEST_LIST_BEGIN
|
VMIME_TEST_LIST_BEGIN
|
||||||
VMIME_TEST(testBadValueType)
|
VMIME_TEST(testBadValueType)
|
||||||
VMIME_TEST(testValueOnNextLine)
|
VMIME_TEST(testValueOnNextLine)
|
||||||
|
VMIME_TEST(testStripSpacesAtEnd)
|
||||||
VMIME_TEST_LIST_END
|
VMIME_TEST_LIST_END
|
||||||
|
|
||||||
|
|
||||||
@ -66,4 +67,20 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
|
|||||||
VASSERT_EQ("Field value", "field data", hvalue->getWholeBuffer());
|
VASSERT_EQ("Field value", "field data", hvalue->getWholeBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testStripSpacesAtEnd()
|
||||||
|
{
|
||||||
|
vmime::parsingContext ctx;
|
||||||
|
|
||||||
|
const vmime::string buffer = "Field: \r\n\tfield data ";
|
||||||
|
|
||||||
|
vmime::ref <vmime::headerField> hfield =
|
||||||
|
vmime::headerField::parseNext(ctx, buffer, 0, buffer.size());
|
||||||
|
|
||||||
|
vmime::ref <vmime::text> hvalue =
|
||||||
|
hfield->getValue().dynamicCast <vmime::text>();
|
||||||
|
|
||||||
|
VASSERT_EQ("Field name", "Field", hfield->getName());
|
||||||
|
VASSERT_EQ("Field value", toHex("field data"), toHex(hvalue->getWholeBuffer()));
|
||||||
|
}
|
||||||
|
|
||||||
VMIME_TEST_SUITE_END
|
VMIME_TEST_SUITE_END
|
||||||
|
Loading…
Reference in New Issue
Block a user