Update of /cvsroot/mahogany/M/src/modules
In directory usw-pr-cvs1:/tmp/cvs-serv14028/src/modules
Modified Files:
Filters.cpp
Log Message:
added spam test for the subject in caps only; fixed memory leak and a UI update
problem in the filter editing dialog
Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.124
retrieving revision 1.125
diff -b -u -2 -r1.124 -r1.125
--- Filters.cpp 2 Jul 2002 22:20:55 -0000 1.124
+++ Filters.cpp 4 Jul 2002 00:05:52 -0000 1.125
@@ -1870,4 +1870,49 @@
// ----------------------------------------------------------------------------
+// check whether the subject contains too many raw 8 bit characters
+static bool CheckSubjectFor8Bit(const String& subject)
+{
+ // consider that the message is a spam if its subject contains more
+ // than half of non alpha numeric chars but isn't properly encoded
+ if ( subject != MailFolder::DecodeHeader(subject) )
+ {
+ // an encoded subject can have 8 bit chars
+ return false;
+ }
+
+ 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 true;
+ }
+ }
+ }
+
+ return false;
+}
+
+// check if the subject is in capitals
+static bool CheckSubjectForCapitals(const String& subject)
+{
+ size_t nLower = 0;
+ for ( const char *pc = subject; *pc; pc++ )
+ {
+ if ( islower(*pc) )
+ {
+ // not only caps
+ return false;
+ }
+ }
+
+ return true;
+}
+
// check the given MIME part and all of its children for Korean charset, return
// true if any of them has it
@@ -2030,28 +2075,9 @@
if ( test == SPAM_TEST_SUBJ8BIT )
{
- // 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;
+ rc = CheckSubjectFor8Bit(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 )
+ else if ( test == SPAM_TEST_SUBJCAPS )
{
- rc = true;
- break;
- }
- }
- }
+ rc = CheckSubjectForCapitals(msg->Subject());
}
else if ( test == SPAM_TEST_KOREAN )
-------------------------------------------------------
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