procmail
[Top] [All Lists]

Re: Chinese-spam filter

2000-02-11 08:04:47
On Fri, 11 Feb 2000 12:57:09 +0100, "Ruud H.G. van Tol"
<rvtol(_at_)isolution(_dot_)nl> wrote:
FORMAIL="/usr/bin/formail"

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

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

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

: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.

  # 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). 

    :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.


  :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,

/* era */

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

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