Added support for mailboxes that specify an (encoded) full name with an empty email address, set by a <> marker (Zarafa).
This commit is contained in:
parent
fbdb750496
commit
4f9dc93200
@ -88,6 +88,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
// Temporary buffers for extracted name and address
|
// Temporary buffers for extracted name and address
|
||||||
string name;
|
string name;
|
||||||
string address;
|
string address;
|
||||||
|
bool hadBrackets = false;
|
||||||
|
|
||||||
while (p < pend)
|
while (p < pend)
|
||||||
{
|
{
|
||||||
@ -283,6 +284,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
}
|
}
|
||||||
else if (*p == '>')
|
else if (*p == '>')
|
||||||
{
|
{
|
||||||
|
hadBrackets = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (!parserHelpers::isSpace(*p))
|
else if (!parserHelpers::isSpace(*p))
|
||||||
@ -309,7 +311,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
|
|
||||||
// Swap name and address when no address was found
|
// Swap name and address when no address was found
|
||||||
// (email address is mandatory, whereas name is optional).
|
// (email address is mandatory, whereas name is optional).
|
||||||
if (address.empty() && !name.empty())
|
if (address.empty() && !name.empty() && !hadBrackets)
|
||||||
{
|
{
|
||||||
m_email.clear();
|
m_email.clear();
|
||||||
m_email.reserve(name.size());
|
m_email.reserve(name.size());
|
||||||
|
@ -32,6 +32,7 @@ VMIME_TEST_SUITE_BEGIN
|
|||||||
|
|
||||||
VMIME_TEST_LIST_BEGIN
|
VMIME_TEST_LIST_BEGIN
|
||||||
VMIME_TEST(testParse)
|
VMIME_TEST(testParse)
|
||||||
|
VMIME_TEST(testEmptyEmailAddress)
|
||||||
VMIME_TEST_LIST_END
|
VMIME_TEST_LIST_END
|
||||||
|
|
||||||
|
|
||||||
@ -113,5 +114,19 @@ VMIME_TEST_SUITE_BEGIN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testEmptyEmailAddress()
|
||||||
|
{
|
||||||
|
vmime::addressList addrList;
|
||||||
|
addrList.parse("\"Full Name\" <>");
|
||||||
|
|
||||||
|
VASSERT_EQ("count", 1, addrList.getAddressCount());
|
||||||
|
VASSERT_EQ("!group", false, addrList.getAddressAt(0)->isGroup());
|
||||||
|
|
||||||
|
vmime::ref <vmime::mailbox> mbox = addrList.getAddressAt(0).dynamicCast <vmime::mailbox>();
|
||||||
|
|
||||||
|
VASSERT_EQ("name", "Full Name", mbox->getName());
|
||||||
|
VASSERT_EQ("email", "", mbox->getEmail());
|
||||||
|
}
|
||||||
|
|
||||||
VMIME_TEST_SUITE_END
|
VMIME_TEST_SUITE_END
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user