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

Modified Files:
        Filters.cpp 
Log Message:
check all MIME parts for the Korean charset in the spam tests, not just the top level 
one

Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -b -u -2 -r1.116 -r1.117
--- Filters.cpp 21 Jun 2002 14:11:02 -0000      1.116
+++ Filters.cpp 26 Jun 2002 18:02:52 -0000      1.117
@@ -1865,4 +1865,25 @@
 #endif
 
+// func_isspam() helper: check the given MIME part and all of its children
+// for Korean charset, return true if any of them has it
+static bool CheckMimePartForKoreanCSet(const MimePart *mimePart)
+{
+   while ( mimePart )
+   {
+      if ( CheckMimePartForKoreanCSet(mimePart->GetNested()) )
+         return true;
+
+      String cset = mimePart->GetParam("charset").Lower();
+      if ( cset == "ks_c_5601-1987" || cset == "euc-kr" )
+      {
+         return true;
+      }
+
+      mimePart = mimePart->GetNext();
+   }
+
+   return false;
+}
+
 static Value func_isspam(ArgList *args, FilterRuleImpl *p)
 {
@@ -1906,7 +1927,13 @@
       if ( test == "subj8bit" )
       {
-         // consider that the message is a spem if its subject contains more
-         // than half of non alpha numeric chars
+         // consider that the message is a spam if its subject contains more
+         // than half of non alpha numeric chars but isn't properly encoded
          String subject = msg->Subject();
+         if ( subject != MailFolder::DecodeHeader(subject) )
+         {
+            // an encoded subject can have 8 bit chars
+            continue;
+         }
+
          size_t num8bit = 0,
                 max8bit = subject.length() / 2;
@@ -1927,32 +1954,7 @@
       else if ( test == "korean" )
       {
-         if ( msg->GetHeaderLine("Content-Type", value) )
-         {
-            // extract the charset parameter
-            static const char *CHARSET_STRING = "charset=";
-            static const size_t CHARSET_LEN = strlen(CHARSET_STRING);
-
-            const char *pc = strstr(value.MakeLower(), CHARSET_STRING);
-            if ( !pc )
-            {
-               // no charset at all, don't filter
-               continue;
-            }
-
-            pc += CHARSET_LEN;
-            if ( *pc == '"' )
-               pc++;
-
-#define STARTS_WITH(p, what) (!(wxStrncmp((p), (what), strlen(what))))
-
-            // detect all Korean charsets
-            if ( STARTS_WITH(pc, "ks_c_5601-1987") ||
-                    STARTS_WITH(pc, "euc-kr") )
-            {
-               rc = true;
-            }
-
-#undef STARTS_WITH
-         }
+         // detect all Korean charsets -- and do it for all MIME parts, not
+         // just the top level one
+         rc = CheckMimePartForKoreanCSet(msg->GetTopMimePart());
       }
       else if ( test == "xauthwarn" )



-------------------------------------------------------
This sf.net email is sponsored by: Jabber Inc.
Don't miss the IM event of the season | Special offer for OSDN members! 
JabberConf 2002, Aug. 20-22, Keystone, CO http://www.jabberconf.com/osdn
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to