procmail
[Top] [All Lists]

Re: Chinese-spam filter

2000-02-11 10:19:50
Ruud:
FORMAIL="/usr/bin/formail"

era:
Usually better IMHO to use PATH to control what programs get executed
than fiddle with one variable per program.

You must be right.


 > # WSP contains a space and a tab:
 > WSP=[     ]
 > NWSP=[^     ]

You need quotes around these assignments. These as such are syntax
errors.

Thanks, must have fallen asleep just before typing them.

:0
* $ ! ^Subject:$WSP*[spam]
{

This means whitespace followed by a single letter which is either a,
m, p, or s. The opening square bracket starts a character class. You
need a backslash in front of it to match a literal opening square
bracket.

Thanks again.


  # block "Received: 202.90-109.*.*"
  :0
  * ^Received:$WSP*.*202\.(10|9)[0-9]\.[0-9]+\.[0-9]
  { CNSPAM=spam1 }

You need a leading $ on the condition to interpolate variables in the
condition ($WSP).

OK.


    :0BD
    * -1^1 .
    *  2^1 =[0-9A-F][0-9A-F]
    * 20^1 [################################] #160-191
    * 20^1 [################################] #192-223
    * 20^1 [################################] #224-255
    * 20^1 =[A-F][0-9A-F]
    { CNSPAM=spam2 }

I don't understand why you penalize quoted-printable =AF pairs with
two extra points. Also ranges are quite permissible even in the upper
high bits; [#-#] 160-255 in a single range is perfectly okay. So you
don't need to break it up on several conditions.

Copied that from www.waltdnes.org, hope Walter reads this too.
His advocacy can be found over there.


  :0         # if CNSPAM is set
  * CNSPAM ??
  {
    MATCH    # unset MATCH
    :0       # if subject has a non-blank character, set MATCH
    * $ ^Subject:$WSP\/$NWSP.*
    {}
             # make Subject-header, even if there was none
    :0 fh w
    | $FORMAIL -A"Subject: [$CNSPAM] $MATCH"
  }

Minor tweak: I would avoid adding a space after [$CNSPAM] if $MATCH is
unset, perhaps like this:

    :0  # note the period here -- otherwise you are not checking anything
    * CNSPAM ?? .
    {
        SUBJTAIL
        :0
        * $ ^Subject:$WSP*\/$NWSP.*
        { SUBJTAIL=" $MATCH" }
        :0fhw  # notice -I instead of -A -- otherwise will be two Subjects
        | formail -I "Subject: [$CNSPAM]$SUBJTAIL"
    }

Hope this helps,

A lot, as always,

Ruud


<Prev in Thread] Current Thread [Next in Thread>