procmail
[Top] [All Lists]

Re: Recipe matching

2001-12-17 01:40:26
From: High Flight <jac(_at_)apk(_dot_)net>

This is an example of recipes which I intend to match ONLY continuous
strings in the "Received" headers which END with    .ch    or    .pl

For example:   ab-cd.efgh.ch

:0
* ^Received:.+\.ch
/u/ja/jac/mail/junk

:0
* ^Received:.*\.ch
/u/ja/jac/mail/junk

First off, the only difference between the two condition lines
would be that `.*' matches zero or more characters while
`.+' matches one or more.  Since you are going to want at
least one at all times if .ch is the 1st-level domain,
you certainly don't need to bother with the dot-star version.



However, procmail is finding a match from these headers:

Received: from smyk.apk.net (smyk.apk.net [207.54.158.17])
      by junior.apk.net (8.11.0/8.11.0/rchk1.22) with ESMTP id
    fAU0lQD09200
      for <Jac(_at_)junior(_dot_)apk(_dot_)net>; Thu, 29 Nov 2001 19:47:26 
-0500 (EST)
Received: from pimout2-int.prodigy.net (pimout2-ext.prodigy.net
    [207.115.63.101]) by smyk.apk.net
    (8.11.2/8.11.2/apk.010219+rchk1.22+bspm1.13.1.5a) with ESMTP id
    fAU0lQJ21131 for <Jac(_at_)apk(_dot_)net>; Thu, 29 Nov 2001 19:47:26 
-0500 (EST)
Received: from oemcomputer (A070-0319.CHCG.splitrock.net [63.254.246.65])
      by pimout2-int.prodigy.net (8.11.0/8.11.0) with SMTP id
    fAU0kx944678;
      Thu, 29 Nov 2001 19:46:59 -0500

Hmm.  If you hadn't quoted the dot in your recipe, the match would
be easy to see: there are both "ch" strings and "pl" strings in
those headers.  But neither one follows a literal dot.  Are you
certain you've actually quoted the dot in your recipe condition lines?
I'll bet not.  But if I'm wrong, then I'd ask as a follow-up
what shell you are running.  Try it with

        SHELL=/bin/sh

near the top of your .procmailrc.


Aside from the above baffling cirmumstance, let's go on to a further
isssue.  Remember (or ascertain from the man pages) that procmail's egrep
parser is minimalistic/non-greedy.  That means that it will stop
on the first match.  Supposing we had as our example string

        abc.ch.com

Your recipes would match, because there is a dot followed by "ch".
You want to tell procmail that there is a word boundary following
the "ch".  It could be a space, tab, `>', or newline.  A suggested way
to handle this would be, as your condition line:

        * ^Received:.+\.ch\>

The `\>' token is a word-boundary signifier to procmail.

-- 
dman+noacks(_at_)nomotek(_dot_)com
_______________________________________________
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>