procmail
[Top] [All Lists]

Re: Virus protection.

2001-02-27 23:36:23
"David W. Tamkin" <dattier(_at_)ripco(_dot_)com> writes:
...
But in any case, what about my original question: if a condition is a non-
negated regexp with no weight or a weight with x=0, doesn't procmail declare
the condition matched and stop egrepping as soon as it finds one match?

Yes.  In fact, when doing weighted matches, if `x' is less than one
in absolute value (i.e., between one and negative one, exclusive) then
procmail will give up after the first match which adds less than one to
the score.  That obviously covers the x=0 case, but it also covers things
like:

        * 8^0.5 foo
        * 6^0.5 foo

The first of those can add at most 8+4+2+1+.5=15.5 to the score in
5 matches.  The second can add at most 6+3+1.5+.75=11.25 and will only
match 4 times.  For proof, put the following in a file "rc" and invoke
procmail as "procmail rc </dev/null"

        VERBOSE=on

        var='foo foo foo'
        :0
        * var ?? 0.25^0
        * var ??    8^0.5 foo
        * var ??    6^0.5 foo
        { }
        :0
        * var ?? 0.5^0
        * var ??   8^0.5 foo
        * var ??   6^0.5 foo
        { }

        var='foo foo foo foo'
        :0
        * var ?? 0.25^0
        * var ??    8^0.5 foo
        * var ??    6^0.5 foo
        { }
        :0
        * var ?? 0.5^0
        * var ??   8^0.5 foo
        * var ??   6^0.5 foo
        { }

        var='foo foo foo foo foo'
        :0
        * var ?? 0.25^0
        * var ??    8^0.5 foo
        * var ??    6^0.5 foo
        { }
        :0
        * var ?? 0.5^0
        * var ??   8^0.5 foo
        * var ??   6^0.5 foo
        { }

        var='foo foo foo foo foo foo'
        :0
        * var ?? 0.25^0
        * var ??    8^0.5 foo
        * var ??    6^0.5 foo
        { }
        :0
        * var ?? 0.5^0
        * var ??   8^0.5 foo
        * var ??   6^0.5 foo
        { }

        HOST

You should get as output something like:

procmail: Assigning "var=foo foo foo"
procmail: Score:       0      +0 ""
procmail: Score:      14      14 "foo"
procmail: Score:      10      24 "foo"
procmail: Score:       0      +0 ""
procmail: Score:      14      14 "foo"
procmail: Score:      10      25 "foo"
procmail: Assigning "var=foo foo foo foo"
procmail: Score:       0      +0 ""
procmail: Score:      15      15 "foo"
procmail: Score:      11      26 "foo"
procmail: Score:       0      +0 ""
procmail: Score:      15      15 "foo"
procmail: Score:      11      26 "foo"
procmail: Assigning "var=foo foo foo foo foo"
procmail: Score:       0      +0 ""
procmail: Score:      15      15 "foo"
procmail: Score:      11      27 "foo"
procmail: Score:       0      +0 ""
procmail: Score:      15      16 "foo"
procmail: Score:      11      27 "foo"
procmail: Assigning "var=foo foo foo foo foo foo"
procmail: Score:       0      +0 ""
procmail: Score:      15      15 "foo"
procmail: Score:      11      27 "foo"
procmail: Score:       0      +0 ""
procmail: Score:      15      16 "foo"
procmail: Score:      11      27 "foo"
procmail: Assigning "HOST"

Procmail does all scoring in floating point using C's `double' type,
though it rounds the values to integers for display (positive numbers are
rounded down, negative number may be rounded either direction depending
on your machine and compiler).  Also note that procmail prints "+0"
when the total score is between zero and one.

If you think you understand why all the values above are what they are,
figure out what it would print if you changed the "0.25^0" to "0.75^0"
in each group, then check yourself by actually doing so.


Philip Guenther

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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