diff --git a/src/messageId.cpp b/src/messageId.cpp index db59ab6a..72cda2a0 100644 --- a/src/messageId.cpp +++ b/src/messageId.cpp @@ -118,7 +118,7 @@ void messageId::parse(const string& buffer, const string::size_type position, // Extract left part const string::size_type leftStart = position + (p - pstart); - while (p < pend && *p != '@') ++p; + while (p < pend && *p != '@' && *p != '>') ++p; m_left = string(buffer.begin() + leftStart, buffer.begin() + position + (p - pstart)); @@ -178,6 +178,9 @@ ref messageId::parseNext(const string& buffer, const string::size_ty const string messageId::getId() const { + if (m_right.empty()) + return m_left; + return (m_left + '@' + m_right); } @@ -193,7 +196,9 @@ void messageId::generate(utility::outputStream& os, const string::size_type maxL pos = NEW_LINE_SEQUENCE_LENGTH; } - os << '<' << m_left << '@' << m_right << '>'; + os << '<' << m_left; + if (m_right != "") os << '@' << m_right; + os << '>'; if (newLinePos) *newLinePos = pos + m_left.length() + m_right.length() + 3; diff --git a/tests/parser/messageIdTest.cpp b/tests/parser/messageIdTest.cpp index e70065a2..40e38ebf 100644 --- a/tests/parser/messageIdTest.cpp +++ b/tests/parser/messageIdTest.cpp @@ -59,12 +59,12 @@ VMIME_TEST_SUITE_BEGIN { vmime::messageId m1; - VASSERT_EQ("1", "<@>", m1.generate()); + VASSERT_EQ("1", "<>", m1.generate()); vmime::messageId m2; m2.setLeft("a"); - VASSERT_EQ("2", "", m2.generate()); + VASSERT_EQ("2", "", m2.generate()); vmime::messageId m3; m3.setRight("b");