procmail
[Top] [All Lists]

Re: scoring twice on one line

2001-09-16 20:20:50
At 6:01 PM +0100 9/16/01, Martin McCarthy wrote:
Firstly, you need to include some of your procmail log after you've
switched VERBOSE logging on.

In particular, the contents of the FROM variable will be quite
revealing, I expect.

Martin,

I think the problem with my original scoring recipe was (as you pointed out), that the '(.*\>)?' don't do anything useful.

My original recipe looked like this:

   :0
   *$ -1^0
   *$  1^1 FROM ?? (.*\<)?(Justin|Kuo)\>
   *$  1^1 FROM ?? (.*\<)?(Cath(y|erine)|Baer)\>
   *$  1^1 FROM ?? (.*\<)?(Eleanor|Chris|Saunders)\>
   { action }

Using your suggestions, I changed it to:

   :0
   * -1^0
   *  1^1 FROM ?? (Justin|Kuo)\>
   *  1^1 FROM ?? (Cath(y|erine)|Baer)\>
   *  1^1 FROM ?? (Eleanor|Chris|Saunders)\>
   { action }

I tested it and it works! The log confirmed the scoring was positive. I did a bit of digging and found a post from Philip Guenther last October that may explain why my original recipe failed. Here's an excerpt:

  When a regexp is being matched multiple times (such as when
  scoring), each search is started where the previous one left
  off. That's how all regexp engines keep from finding the
  same match over and over again.

Even after reading the explanation I'm still puzzled as to what the regexp was actually doing.

In the following recipe, $NSPC is set beforehand.

Set to what?  Something like
  NSPC="[^ ]"
?  I'll assume that for now.

Yes, you were correct. NSPC means "not space or tab character."


  :0
  *$ ! ^Reply-to: *\/$NSPC.*
  *$ ! ^From: *\/$NSPC.*
  *$ ! ^Sender: *\/$NSPC.*
  *$ ! ^From *\/$NSPC+
  *$ ! ^X-Envelope: *\/$NSPC.*
  {
      FROM = `formail -xFrom:`
  }

If Reply-to: and From: headers aren't present it will try to set MATCH
to just the *first* non-space "word" on the "From " line - is that what
you meant?

I copied the FROM recipe from a posting while learning about Procmail. It looks like a typo that should be changed to:

  *$ ! ^From *\/$NSPC.*

Also, the action here (set FROM to be whatever is in the From: header)
is only invoked if there is no From: header (amongst other things).
Which doesn't seem entirely right.

There was an "else" statment. My complete FROM receipe is:

  :0
  *$ ! ^Reply-to: *\/$NSPC.*
  *$ ! ^From: *\/$NSPC.*
  *$ ! ^Sender: *\/$NSPC.*
  *$ ! ^From *\/$NSPC.*
  *$ ! ^X-Envelope: *\/$NSPC.*
  {
      FROM = `formail -xFrom:`
  }
  :0 E
  {
      FROM = $MATCH
  }

  :0
  *$ -1^0
  *$  1^1 FROM ?? (.*\<)?(Justin|Kuo)\>
  *$  1^1 FROM ?? (.*\<)?(Cath(y|erine)|Baer)\>
  *$  1^1 FROM ?? (.*\<)?(Eleanor|Chris|Saunders)\>

The '$'s are unnecessary here as you aren't expanding any variables.
Also the '(.*\>)?' don't do anything useful.

You can see that the principle is quite sound with a test recipe that
explicitly sets the FROM variable such as:

FROM='"Justin Kuo" <kuo(_at_)world(_dot_)std(_dot_)com>"'
:0
* -1^0
* 1^1 FROM ?? (Justin|Kuo)\>
{ }

FROM='"Kuo, Justin" <kuo(_at_)theworld(_dot_)com>'
:0
* -1^0
* 1^1 FROM ?? (Justin|Kuo)\>
{ }

and looking at the verbose log - you'll see that the recipes have
positive scores like you expect.  Which perhaps suggests that FROM isn't
being set to what you expect.  Scoring is doing what you think it
should - it's the other parts that aren't!

Thanks for your help.  --  Justin
---------- Race Walking ONLINE at http://www.racewalk.com ----------
   Reply to Justin Kuo jkuo(_at_)usatfne(_dot_)org or 
jkuo(_at_)meditech(_dot_)com
     home 617-731-9889  FAX 786-513-8170  work 781-774-5410
--- Call the N.E.W. Hotline 781-433-7142 for latest RW schedules ---
_______________________________________________
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>