Fix for message ids without angle brackets.

This commit is contained in:
Vincent Richard 2006-08-09 07:18:45 +00:00
parent 2a39997480
commit 3abf3bdcb8
3 changed files with 24 additions and 2 deletions

View File

@ -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) if (p < pend)
{ {
// Extract left part // Extract left part
@ -119,7 +131,7 @@ void messageId::parse(const string& buffer, const string::size_type position,
// Extract right part // Extract right part
const string::size_type rightStart = position + (p - pstart); 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, m_right = string(buffer.begin() + rightStart,
buffer.begin() + position + (p - pstart)); buffer.begin() + position + (p - pstart));

View File

@ -32,6 +32,7 @@ VMIME_TEST_SUITE_BEGIN
VMIME_TEST_LIST_BEGIN VMIME_TEST_LIST_BEGIN
VMIME_TEST(testParse) VMIME_TEST(testParse)
VMIME_TEST(testParseInvalid)
VMIME_TEST(testGenerate) VMIME_TEST(testGenerate)
VMIME_TEST_LIST_END VMIME_TEST_LIST_END
@ -45,6 +46,15 @@ VMIME_TEST_SUITE_BEGIN
VASSERT_EQ("1.2", "b", m1.getRight()); 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() void testGenerate()
{ {
vmime::messageId m1; vmime::messageId m1;

View File

@ -48,7 +48,7 @@
#include <stdexcept> #include <stdexcept>
//#define DEBUG_RESPONSE 1 #define DEBUG_RESPONSE 1
#if DEBUG_RESPONSE #if DEBUG_RESPONSE