Update of /cvsroot/mahogany/M/src/modules
In directory usw-pr-cvs1:/tmp/cvs-serv7829/src/modules
Modified Files:
Filters.cpp
Log Message:
improved HTML spam test to catch the invalid MIME messages
Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -b -u -2 -r1.122 -r1.123
--- Filters.cpp 1 Jul 2002 15:03:48 -0000 1.122
+++ Filters.cpp 2 Jul 2002 21:51:31 -0000 1.123
@@ -1864,8 +1864,12 @@
}
-#endif
+#endif // USE_RBL
-// func_isspam() helper: check the given MIME part and all of its children
-// for Korean charset, return true if any of them has it
+// ----------------------------------------------------------------------------
+// SPAM tests: different functions below are all used by func_isspam()
+// ----------------------------------------------------------------------------
+
+// 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 *part)
{
@@ -1887,17 +1891,15 @@
}
-// another func_isspam() helper: check the value of X-Spam-Status
-// header and return true if we believe it indicates that this is a spam
+// check the value of X-Spam-Status header and return true if we believe it
+// indicates that this is a spam
static bool CheckXSpamStatus(const String& value)
{
- // check for "^.*^X-Spam-Status: Yes+$" regex manually
- if ( value.Lower().StartsWith("yes") )
- return true;
-
- return false;
+ // SpamAssassin adds header "X-Spam-Status: Yes" for the messages it
+ // believes to be spams, so simply check if the header value looks like this
+ return value.Lower().StartsWith("yes");
}
-// another func_isspam() helper: check the value of X-Authentication-Warning
-// header and return true if we believe it indicates that this is a spam
+// check the value of X-Authentication-Warning header and return true if we
+// believe it indicates that this is a spam
static bool CheckXAuthWarning(const String& value)
{
@@ -1940,4 +1942,51 @@
}
+// check if we have an HTML-only message
+static bool CheckForHTMLOnly(const Message *msg)
+{
+ const MimePart *part = msg->GetTopMimePart();
+ if ( !part )
+ {
+ // no MIME info at all?
+ return false;
+ }
+
+ // we accept the multipart/alternative messages with a text/plain and
+ // a text/html part but not the top level text/html messages
+ //
+ // the things are further complicated by the fact that some spammers send
+ // HTML messages without MIME-Version header which results in them
+ // [correctly] not being recognizad as MIME by c-client at all and so they
+ // have the default type of text/plain and we have to check for this
+ // (common) case specially
+ const MimeType type = part->GetType();
+ if ( type.GetPrimary() == MimeType::TEXT )
+ {
+ String subtype = type.GetSubType();
+
+ if ( subtype == "PLAIN" )
+ {
+ // check if it was really in the message or returned by c-client in
+ // absence of MIME-Version
+ String value;
+ if ( !msg->GetHeaderLine("MIME-Version", value) )
+ {
+ if ( msg->GetHeaderLine("Content-Type", value) )
+ {
+ if ( strstr(value.MakeLower(), "text/html") )
+ return true;
+ }
+ }
+ }
+ else if ( subtype == "HTML" )
+ {
+ return true;
+ }
+ }
+ //else: it's a MIME message but of non TEXT type
+
+ return false;
+}
+
static Value func_isspam(ArgList *args, FilterRuleImpl *p)
{
@@ -2028,8 +2077,5 @@
else if ( test == SPAM_TEST_HTML )
{
- // we accept the multipart/alternative messages with a text/plain and
- // a text/html part but not the top level text/html messages
- const MimePart *part = msg->GetTopMimePart();
- rc = part && part->GetType().GetFull() == "TEXT/HTML";
+ rc = CheckForHTMLOnly(msg.operator->());
}
#ifdef USE_RBL
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
No, I will not fix your computer.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates