Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1:/tmp/cvs-serv17300/src/modules

Modified Files:
        Filters.cpp 
Log Message:
Match List-Id correctly and ignore parameters at end of mailto

Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.173
retrieving revision 1.174
diff -b -u -2 -r1.173 -r1.174
--- Filters.cpp 17 Oct 2003 13:33:32 -0000      1.173
+++ Filters.cpp 17 Oct 2003 14:36:10 -0000      1.174
@@ -2309,4 +2309,51 @@
 }
 
+static bool WhiteListDomain(RefCounter<AdbBook> book,const String &candidate)
+{
+   wxArrayString domains(GenerateSuperDomains(candidate));
+   
+   for( size_t super = 0; super < domains.GetCount(); ++super )
+   {
+      // FIXME: Grammar without escape sequences
+      if( book->Matches(String(_T("*@"))+domains[super],
+            AdbLookup_EMail,AdbLookup_Match) )
+      {
+         return false;
+      }
+      
+      // Allow whitelisting domain itself
+      if( book->Matches(domains[super],AdbLookup_EMail,AdbLookup_Match) )
+      {
+         return false;
+      }
+   }
+   
+   return true;
+}
+
+static bool WhiteListListId(RefCounter<AdbBook> book,const String &id)
+{
+   size_t left = id.find(_T('<'));
+   if( left != String::npos )
+   {
+      size_t right = id.find(_T('>'),left);
+      if( right != String::npos )
+      {
+         size_t at = id.find(_T('@'),left);
+         
+         size_t begin;
+         if( at != String::npos && at < right )
+            begin = at;
+         else
+            begin = left;
+         
+         if( !WhiteListDomain(book,id.substr(begin+1,right-(begin+1))) )
+            return false;
+      }
+   }
+   
+   return true;
+}
+
 // check whether any address field (sender or recipient) matches whitelist
 // FIXME: Match address groups ([EMAIL PROTECTED]) and domains
@@ -2324,5 +2371,5 @@
       _T("Bcc"),
       // List
-      _T("List-Id"),
+      //_T("List-Id"), // List-Id may contain all sorts of garbage (see below)
       _T("List-Help"),
       _T("List-Subscribe"),
@@ -2369,22 +2416,14 @@
       candidate = parser->GetNext(candidate) )
    {
-      wxArrayString domains(GenerateSuperDomains(candidate->GetDomain()));
-      
-      for( size_t super = 0; super < domains.GetCount(); ++super )
-      {
-         // FIXME: Grammar without escape sequences
-         if( book->Matches(String(_T("*@"))+domains[super],
-               AdbLookup_EMail,AdbLookup_Match) )
-         {
+      if( !WhiteListDomain(book,candidate->GetDomain()) )
             return false;
          }
          
-         // Allow whitelisting domain itself
-         if( book->Matches(domains[super],AdbLookup_EMail,AdbLookup_Match) )
+   String id;
+   if( msg->GetHeaderLine(_T("List-Id"),id) )
          {
+      if( !WhiteListListId(book,id) )
             return false;
          }
-      }
-   }
 
    return true;



-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to