Let whitespace break the value of a parameterized header field, not just a ';' (thanks to Zarafa).

This commit is contained in:
Vincent Richard 2013-03-24 11:35:08 +01:00
parent 1d04b0a579
commit 495526a5e6
2 changed files with 19 additions and 1 deletions

View File

@ -98,7 +98,7 @@ void parameterizedHeaderField::parseImpl
// Advance up to ';', if any
string::size_type valueLength = 0;
while (p < pend && *p != ';') // FIXME: support ";" inside quoted or RFC-2047-encoded text
while (p < pend && *p != ';' && (!parserHelpers::isSpace(*p))) // FIXME: support ";" inside quoted or RFC-2047-encoded text
{
++p;
++valueLength;
@ -119,6 +119,12 @@ void parameterizedHeaderField::parseImpl
{
std::map <string, paramInfo> params;
if (*p != ';')
{
while (p < pend && *p != ';') // FIXME: support ";" inside quoted or RFC-2047-encoded text
++p;
}
while (*p == ';')
{
// Skip ';'

View File

@ -35,6 +35,7 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
VMIME_TEST(testParseNonSignificantWS)
VMIME_TEST(testEncodeTSpecials)
VMIME_TEST(testEncodeTSpecialsInRFC2231)
VMIME_TEST(testWhitespaceBreaksTheValue)
VMIME_TEST_LIST_END
@ -348,5 +349,16 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
vmime::create <vmime::parameter>("filename", "my_file_name_\xc3\xb6\xc3\xa4\xc3\xbc_(1).txt")->generate());
}
void testWhitespaceBreaksTheValue()
{
parameterizedHeaderField p;
p.parse("xxx yyy; param1=value1 \r\n");
VASSERT_EQ("count", 1, p.getParameterCount());
VASSERT_EQ("value", "xxx", FIELD_VALUE(p));
VASSERT_EQ("param1.name", "param1", PARAM_NAME(p, 0));
VASSERT_EQ("param1.value", "value1", PARAM_VALUE(p, 0));
}
VMIME_TEST_SUITE_END