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

Modified Files:
        Filters.cpp 
Log Message:
added a dialog to configure the spam detection options and a test for ks_c_5601 charset


Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -b -u -2 -r1.114 -r1.115
--- Filters.cpp 18 Jun 2002 22:04:25 -0000      1.114
+++ Filters.cpp 20 Jun 2002 18:12:46 -0000      1.115
@@ -1865,18 +1865,77 @@
 #endif
 
-static Value func_checkSpam(ArgList *args, FilterRuleImpl *p)
+static Value func_isspam(ArgList *args, FilterRuleImpl *p)
 {
-   // standard check:
-   if(args->Count() != 0)
-      return Value("");
+   String arg;
+   switch ( args->Count() )
+   {
+      case 0:
+         // for compatibility: before, this function didn't take any arguments
+         // and only checked the RBL
+         arg = "rbl";
+         break;
 
-   bool rc = false;
+      case 1:
+         arg = args->GetArg(0)->Evaluate().GetString();
+         break;
 
-   Message_obj msg = p->GetMessage();
-   if ( msg )
+      default:
+         return Value();
+   }
+
+   wxArrayString tests = strutil_restore_array(arg);
+   size_t count = tests.GetCount();
+
+   if ( !count )
    {
+      wxLogWarning(_("No SPAM tests configured, please edit this filter rule."));
+
+      return Value();
+   }
+
+   Message_obj msg = p->GetMessage();
+   if ( !msg )
+      return false;
+
       String value;
 
+   bool rc = false;
+   for ( size_t n = 0; n < count && !rc; n++ )
+   {
+      const wxString& test = tests[n];
+      if ( test == "subj8bit" )
+      {
+         // consider that the message is a spem if its subject contains more
+         // than half of non alpha numeric chars
+         String subject = msg->Subject();
+         size_t num8bit = 0,
+                max8bit = subject.length() / 2;
+         for ( const unsigned char *pc = (const unsigned char *)subject.c_str();
+               *pc;
+               pc++ )
+         {
+            if ( *pc > 127 || *pc == '?' || *pc == '!' )
+            {
+               if ( num8bit++ == max8bit )
+               {
+                  rc = true;
+                  break;
+               }
+            }
+         }
+      }
+      else if ( test == "korean" )
+      {
+         rc = msg->GetHeaderLine("Content-Type", value) &&
+               value.Lower().find("ks_c_5601-1987") != String::npos;
+      }
+      else if ( test == "xauthwarn" )
+      {
+         // consider that only spams have this header
+         rc = msg->GetHeaderLine("X-Authentication-Warning", value);
+      }
 #ifdef USE_RBL
+      else if ( test == "rbl" )
+      {
       msg->GetHeaderLine("Received", value);
 
@@ -1919,11 +1978,6 @@
 
       /*FIXME: if it is a hostname, maybe do a DNS lookup first? */
-
-      if ( !rc )
-#endif // USE_RBL
-      {
-         // consider that only spams have this header
-         rc = msg->GetHeaderLine("X-Authentication-Warning", value);
       }
+#endif // USE_RBL
    }
 
@@ -2036,33 +2090,4 @@
 }
 
-static Value func_subj8bit(ArgList *args, FilterRuleImpl *p)
-{
-   if(args->Count() != 0)
-      return Value(false);
-
-   Message_obj msg = p->GetMessage();
-   if(! msg)
-      return Value(false);
-
-   // consider that the subject is 8 bit if it contains more than half of 8 bit
-   // chars
-   String subject = msg->Subject();
-   size_t num8bit = 0,
-          max8bit = subject.length() / 2;
-   for ( const unsigned char *pc = (const unsigned char *)subject.c_str();
-         *pc; pc++ )
-   {
-      if ( *pc > 127 || *pc == '?' || *pc == '!' )
-      {
-         if ( num8bit++ == max8bit )
-         {
-            return Value(true);
-         }
-      }
-   }
-
-   return Value(false);
-}
-
 #ifdef USE_PYTHON
 static Value func_python(ArgList *args, FilterRuleImpl *p)
@@ -2497,5 +2522,5 @@
          Define("size", func_size);
          Define("now", func_now);
-         Define("isspam", func_checkSpam);
+         Define("isspam", func_isspam);
          Define("expunge", func_expunge);
          Define("python", func_python);
@@ -2505,5 +2530,4 @@
          Define("addscore", func_addscore);
          Define("istome", func_istome);
-         Define("subj8bit", func_subj8bit);
 #ifdef TEST
          Define("nargs", func_nargs);



-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to