From 495526a5e6c04f2564741a54d791705cdaa268f7 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 24 Mar 2013 11:35:08 +0100 Subject: [PATCH] Let whitespace break the value of a parameterized header field, not just a ';' (thanks to Zarafa). --- src/parameterizedHeaderField.cpp | 8 +++++++- tests/parser/parameterTest.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/parameterizedHeaderField.cpp b/src/parameterizedHeaderField.cpp index 619fe7cf..c4e0b368 100644 --- a/src/parameterizedHeaderField.cpp +++ b/src/parameterizedHeaderField.cpp @@ -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 params; + if (*p != ';') + { + while (p < pend && *p != ';') // FIXME: support ";" inside quoted or RFC-2047-encoded text + ++p; + } + while (*p == ';') { // Skip ';' diff --git a/tests/parser/parameterTest.cpp b/tests/parser/parameterTest.cpp index eb3a663a..3ebd6e35 100644 --- a/tests/parser/parameterTest.cpp +++ b/tests/parser/parameterTest.cpp @@ -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 ("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