Fix for message ids without angle brackets.
This commit is contained in:
parent
2a39997480
commit
3abf3bdcb8
@ -101,6 +101,18 @@ void messageId::parse(const string& buffer, const string::size_type position,
|
||||
}
|
||||
}
|
||||
|
||||
// Fix for message ids without angle brackets (invalid)
|
||||
bool hasBrackets = true;
|
||||
|
||||
if (p == pend) // no opening angle bracket found
|
||||
{
|
||||
hasBrackets = false;
|
||||
p = pstart;
|
||||
|
||||
while (p < pend && parserHelpers::isSpace(*p))
|
||||
++p;
|
||||
}
|
||||
|
||||
if (p < pend)
|
||||
{
|
||||
// Extract left part
|
||||
@ -119,7 +131,7 @@ void messageId::parse(const string& buffer, const string::size_type position,
|
||||
// Extract right part
|
||||
const string::size_type rightStart = position + (p - pstart);
|
||||
|
||||
while (p < pend && *p != '>') ++p;
|
||||
while (p < pend && *p != '>' && (hasBrackets || !parserHelpers::isSpace(*p))) ++p;
|
||||
|
||||
m_right = string(buffer.begin() + rightStart,
|
||||
buffer.begin() + position + (p - pstart));
|
||||
|
@ -32,6 +32,7 @@ VMIME_TEST_SUITE_BEGIN
|
||||
|
||||
VMIME_TEST_LIST_BEGIN
|
||||
VMIME_TEST(testParse)
|
||||
VMIME_TEST(testParseInvalid)
|
||||
VMIME_TEST(testGenerate)
|
||||
VMIME_TEST_LIST_END
|
||||
|
||||
@ -45,6 +46,15 @@ VMIME_TEST_SUITE_BEGIN
|
||||
VASSERT_EQ("1.2", "b", m1.getRight());
|
||||
}
|
||||
|
||||
void testParseInvalid()
|
||||
{
|
||||
vmime::messageId m1;
|
||||
m1.parse("foo@bar");
|
||||
|
||||
VASSERT_EQ("1.1", "foo", m1.getLeft());
|
||||
VASSERT_EQ("1.2", "bar", m1.getRight());
|
||||
}
|
||||
|
||||
void testGenerate()
|
||||
{
|
||||
vmime::messageId m1;
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
//#define DEBUG_RESPONSE 1
|
||||
#define DEBUG_RESPONSE 1
|
||||
|
||||
|
||||
#if DEBUG_RESPONSE
|
||||
|
Loading…
Reference in New Issue
Block a user