Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1:/tmp/cvs-serv26422/src/modules
Modified Files:
Filters.cpp
Log Message:
Simple whitelist support
Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.155
retrieving revision 1.156
diff -b -u -2 -r1.155 -r1.156
--- Filters.cpp 25 Sep 2003 15:13:08 -0000 1.155
+++ Filters.cpp 26 Sep 2003 09:33:44 -0000 1.156
@@ -35,4 +35,5 @@
#ifndef USE_PCH
# include "Mcommon.h"
+# include "Mdefaults.h"
# include <wx/frame.h> // for wxFrame
@@ -45,4 +46,7 @@
#include "UIdArray.h"
#include "Message.h"
+#include "adb/AdbManager.h"
+#include "adb/AdbBook.h"
+#include "adb/AdbEntry.h"
#include "gui/wxMDialogs.h" // for MProgressDialog
@@ -50,4 +54,12 @@
#include <wx/regex.h> // wxRegEx::Flags
+class MOption;
+
+// ----------------------------------------------------------------------------
+// options we use here
+// ----------------------------------------------------------------------------
+
+extern const MOption MP_WHITE_LIST;
+
// ----------------------------------------------------------------------------
// global variables
@@ -2272,4 +2284,81 @@
}
+// check whether any address field (sender or recipient) matches whitelist
+// FIXME: Match address groups ([EMAIL PROTECTED]) and domains
+static bool CheckWhiteList(const Message *msg)
+{
+ static const char *headers[] =
+ {
+ // Source
+ "From",
+ "Sender",
+ "Reply-To",
+ // Destination
+ "To",
+ "Cc",
+ "Bcc",
+ // List
+ "List-Id",
+ "List-Help",
+ "List-Subscribe",
+ "List-Unsubscribe",
+ "List-Post",
+ "List-Owner",
+ "List-Archive",
+ // Obscure
+ "Resent-To",
+ "Resent-Cc",
+ "Resent-Bcc",
+ "Resent-From",
+ "Resent-Sender",
+ // Non-standard - some entries can be probably removed without danger
+ "Envelope-To", // Exim
+ "X-Envelope-To", // Sendmail
+ "Apparently-To", // Procmail ^TO
+ "X-Envelope-From", // Procmail ^FROM_DAEMON
+ "Mailing-List", // Ezmlm and Yahoo
+ "X-Mailing-List", // SmartList
+ "X-BeenThere", // Mailman
+ "Delivered-To", // qmail
+ "X-Delivered-To", // fastmail.fm
+ "X-Original-To", // postfix 2.0
+ "X-Rcpt-To", // best.com
+ "X-Real-To", // CommuniGate Pro
+ "X-MDMailing-List", // Nancy Mc'Gough's Procmail Faq
+ "Return-Path", // Nancy Mc'Gough's Procmail Faq
+ NULL
+ };
+
+ wxArrayString values = msg->GetHeaderLines(headers);
+ wxString list = strutil_flatten_array(values, ',');
+ list.MakeLower();
+
+ AdbManager *manager = AdbManager::Get();
+ manager->LoadAll(); // HACK: So that AdbEditor's provider list is utilized
+ AdbBook *book = manager->CreateBook(READ_APPCONFIG_TEXT(MP_WHITE_LIST));
+ manager->Unget();
+
+ wxArrayString names;
+ book->GetEntryNames(names);
+
+ bool found = false;
+ for( size_t each = 0; each < names.GetCount(); ++each )
+ {
+ AdbEntry *entry = book->GetEntry(names[each]);
+
+ wxString address;
+ entry->GetField(AdbField_EMail,&address);
+ address.MakeLower();
+
+ found = found || list.find(address) != wxString::npos;
+
+ entry->DecRef();
+ }
+
+ book->DecRef();
+
+ return !found;
+}
+
// check if we have a message with "suspicious" MIME structure
static bool CheckForSuspiciousMIME(const Message *msg)
@@ -2397,4 +2486,9 @@
if ( CheckForHTMLOnly(msg.Get()) )
gs_spamTest = _("pure HTML content");
+ }
+ else if ( test == SPAM_TEST_WHITE_LIST )
+ {
+ if ( CheckWhiteList(msg.Get()) )
+ gs_spamTest = _("not in whitelist");
}
#ifdef USE_RBL
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates