Fixed parsing header field value on next line.
This commit is contained in:
parent
005e7af6cd
commit
84415da8e1
@ -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 = 0;
|
string::size_type contentsEnd = end;
|
||||||
|
|
||||||
// Extract the field value
|
// Extract the field value
|
||||||
while (pos < end)
|
while (pos < end)
|
||||||
|
@ -28,6 +28,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_LIST_END
|
VMIME_TEST_LIST_END
|
||||||
|
|
||||||
|
|
||||||
@ -49,4 +50,20 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
|
|||||||
custom->setValue(vmime::text("field value text")));
|
custom->setValue(vmime::text("field value text")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testValueOnNextLine()
|
||||||
|
{
|
||||||
|
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", "field data", hvalue->getWholeBuffer());
|
||||||
|
}
|
||||||
|
|
||||||
VMIME_TEST_SUITE_END
|
VMIME_TEST_SUITE_END
|
||||||
|
@ -124,6 +124,23 @@ public:
|
|||||||
void setValue(const string& value);
|
void setValue(const string& value);
|
||||||
|
|
||||||
|
|
||||||
|
/** Parse a header field from a buffer.
|
||||||
|
*
|
||||||
|
* @param ctx parsing context
|
||||||
|
* @param buffer input buffer
|
||||||
|
* @param position current position in the input buffer
|
||||||
|
* @param end end position in the input buffer
|
||||||
|
* @param newPosition will receive the new position in the input buffer
|
||||||
|
* @return parsed header field, or NULL if no more header field can be parsed
|
||||||
|
* in the input buffer
|
||||||
|
*/
|
||||||
|
static ref <headerField> parseNext
|
||||||
|
(const parsingContext& ctx,
|
||||||
|
const string& buffer,
|
||||||
|
const string::size_type position,
|
||||||
|
const string::size_type end,
|
||||||
|
string::size_type* newPosition = NULL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void parseImpl
|
void parseImpl
|
||||||
@ -140,14 +157,6 @@ protected:
|
|||||||
string::size_type* newLinePos = NULL) const;
|
string::size_type* newLinePos = NULL) const;
|
||||||
|
|
||||||
|
|
||||||
static ref <headerField> parseNext
|
|
||||||
(const parsingContext& ctx,
|
|
||||||
const string& buffer,
|
|
||||||
const string::size_type position,
|
|
||||||
const string::size_type end,
|
|
||||||
string::size_type* newPosition = NULL);
|
|
||||||
|
|
||||||
|
|
||||||
string m_name;
|
string m_name;
|
||||||
ref <headerFieldValue> m_value;
|
ref <headerFieldValue> m_value;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user