SF.net SVN: mahogany: [7210] trunk/M/src/mail/Address.cpp

[email protected]
Newsgroups gmane.mail.mahogany.cvs
Message-ID <[email protected]>
Revision: 7210
          http://svn.sourceforge.net/mahogany/?rev=7210&view=rev
Author:   vadz
Date:     2007-01-08 15:32:01 -0800 (Mon, 08 Jan 2007)

Log Message:
-----------
correct comparison for addresses containing the personal name and not just email address in IsInList()

Modified Paths:
--------------
    trunk/M/src/mail/Address.cpp

Modified: trunk/M/src/mail/Address.cpp
===================================================================
--- trunk/M/src/mail/Address.cpp	2007-01-08 22:18:37 UTC (rev 7209)
+++ trunk/M/src/mail/Address.cpp	2007-01-08 23:32:01 UTC (rev 7210)
@@ -272,20 +272,36 @@
    {
       for ( size_t n = 0; n < count; n++ )
       {
-         // first tokenize this string: it can be a full address or domain name
-         // only and it may contain '?' and '*' shell pattern metacharacters
          const wxChar * const start = addresses[n];
 
-         const wxChar *p = wxStrchr(start, _T('@'));
+         // first obtain the address part only: we don't care about everything
+         // else, "Foo <[email protected]>" and "Bar <[email protected]>" are the same
+         //
+         // NB: this is of course not a correct way to parse an address but we
+         //     can't use AddressList here as this might be just a domain name
+         //     and not a valid address
+         const wxChar *startAddr = wxStrchr(start, _T('<')),
+                      *endAddr = NULL;
+         if ( startAddr )
+            endAddr = wxStrchr(++startAddr, _T('>'));
+         else
+            startAddr = start;
+
+         if ( !endAddr )
+            endAddr = start + addresses[n].length();
+
+         // next tokenize this string: it can be a full address or domain name
+         // only and it may contain '?' and '*' shell pattern metacharacters
+         const wxChar *p = wxStrchr(startAddr, _T('@'));
          if ( p )
          {
-            mailbox.assign(start, p - start);
-            domain = p + 1;
+            mailbox.assign(startAddr, p - startAddr);
+            domain.assign(p + 1, endAddr);
          }
          else // no mailbox part, domain only given
          {
             mailbox = _T('*');
-            domain = start;
+            domain.assign(startAddr, endAddr);
          }
 
          // now we can finally compare the addresses


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.