aboutsummaryrefslogtreecommitdiffstats
path: root/src/address.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-03-11 10:05:09 +0100
committerVincent Richard <[email protected]>2013-03-11 10:05:09 +0100
commit32a80f6c1ed501ceb2e1d7613dcdcce6cdf6fe23 (patch)
tree72f7ac0894025d16b8dca950fdfe2df97972faf6 /src/address.cpp
parentRefactored unit tests. (diff)
downloadvmime-32a80f6c1ed501ceb2e1d7613dcdcce6cdf6fe23.tar.gz
vmime-32a80f6c1ed501ceb2e1d7613dcdcce6cdf6fe23.zip
Fixed mailbox and mailbox group parsing. Added unit tests.
Diffstat (limited to 'src/address.cpp')
-rw-r--r--src/address.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/address.cpp b/src/address.cpp
index ab207cf6..b57892d5 100644
--- a/src/address.cpp
+++ b/src/address.cpp
@@ -68,7 +68,7 @@ address-list = (address *("," address)) / obs-addr-list
ref <address> address::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
- const string::size_type end, string::size_type* newPosition)
+ const string::size_type end, string::size_type* newPosition, bool *isLastAddressOfGroup)
{
bool escaped = false;
bool quoted = false;
@@ -76,6 +76,10 @@ ref <address> address::parseNext
bool inRouteAddr = false;
bool isGroup = false;
bool stop = false;
+ int commentLevel = 0;
+
+ if (isLastAddressOfGroup)
+ *isLastAddressOfGroup = false;
string::size_type pos = position;
@@ -106,9 +110,22 @@ ref <address> address::parseNext
case '>':
inRouteAddr = false;
break;
+
+ case '(':
+
+ ++commentLevel;
+ break;
+
+ case ')':
+
+ if (commentLevel > 0)
+ --commentLevel;
+
+ break;
+
case '=':
- if (!quoted && !quotedRFC2047 && pos + 1 < end && buffer[pos + 1] == '?')
+ if (commentLevel == 0 && !quoted && !quotedRFC2047 && pos + 1 < end && buffer[pos + 1] == '?')
{
++pos;
quotedRFC2047 = true;
@@ -118,7 +135,7 @@ ref <address> address::parseNext
case '?':
- if (quotedRFC2047 && pos + 1 < end && buffer[pos + 1] == '=')
+ if (commentLevel == 0 && quotedRFC2047 && pos + 1 < end && buffer[pos + 1] == '=')
{
++pos;
quotedRFC2047 = false;
@@ -128,7 +145,7 @@ ref <address> address::parseNext
default:
{
- if (!quoted && !quotedRFC2047 && !inRouteAddr)
+ if (commentLevel == 0 && !quoted && !quotedRFC2047 && !inRouteAddr)
{
switch (buffer[pos])
{
@@ -140,6 +157,9 @@ ref <address> address::parseNext
++pos;
}
+ if (isLastAddressOfGroup)
+ *isLastAddressOfGroup = true;
+
stop = true;
break;