[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vps-mail] procmail escaping of non alphanumerics



On Tue, Oct 28, 2003 at 02:19:07PM +0100, Sikaspam wrote:
> >;;+, or \.(\.)+, or [$][$]+, etc. Regrettably, procmail does not
> >implement newer egrep extensions.
> 
> Those would only work if consecutive, right?

Right. That's the substitution for {2,} you asked for. If you mean to
apply the counting to the entire body (or a line), you'll have to use
scoring. Something like this might work for you:

<snip>
## define "bad" characters in terms of "not good characters"
GOODHDRS=[:a-z0-9\ ]
BADHDRS=[^:a-z0-9\ ]

:0

## match the subject line and save it for later. Remember,
## procmail is greedy to right of \/ operator (always stingy
## otherwise). This means we need to match the first non-space
## character right of the \/ to allow the [         ] on the left to
## match as much as possible.
* ^Subject:[ 	]*\/[^ 	].*
{
    :0

    ## 2 "gimme" points. If Subject has more than 3 bad chars,
    ## this recipe will match
    * -2^0

    ## count how many bad chars this Subject has
    * 1^1 $ MATCH ?? ${BADHDRS}
    {
        LOG="Found $= bad (+gimmes) chars in subject
"
        :0:
        /var/tmp/badchars
    }
}
</snip>

> However, two or more semicolons would be useful. I was wondering about 
> the use of scoring - I guess you'll be getting to that soon in your 
> tutorials :)

In a few weeks, probably. This week (hopefully) we'll be doing
non-delivering recipes (filters, etc.) I might use this example!

Scott
-- 
Scott Wiersdorf
scott@xxxxxxxxxxxx
======================================================================
This is <vps-mail@xxxxxxxxxxxx>       <http://www.perlcode.org/lists/>
======================================================================


Main Index | Thread Index
Match: Format: Sort by:
Search: