aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/messageId.cpp14
-rw-r--r--tests/parser/messageIdTest.cpp10
-rw-r--r--vmime/net/imap/IMAPParser.hpp2
3 files changed, 24 insertions, 2 deletions
diff --git a/src/messageId.cpp b/src/messageId.cpp
index 407c859a..f749148c 100644
--- a/src/messageId.cpp
+++ b/src/messageId.cpp
@@ -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));
diff --git a/tests/parser/messageIdTest.cpp b/tests/parser/messageIdTest.cpp
index a7a2a97c..6330f157 100644
--- a/tests/parser/messageIdTest.cpp
+++ b/tests/parser/messageIdTest.cpp
@@ -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;
diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp
index da812952..c535e1aa 100644
--- a/vmime/net/imap/IMAPParser.hpp
+++ b/vmime/net/imap/IMAPParser.hpp
@@ -48,7 +48,7 @@
#include <stdexcept>
-//#define DEBUG_RESPONSE 1
+#define DEBUG_RESPONSE 1
#if DEBUG_RESPONSE