On 2 Sep, Andrew Edelstein wrote:
| On Sat, Sep 01, 2001 at 06:33:33PM +0700, Tim Rice wrote:
| > I tried this and it fails to match "Invalid recipient:"
| >
| > :0B:
| > * ^Invalid recipient: \<\/\>
| > | $MATCH >> $HOME/.blacklistglobal
|
| You haven't really told it what to match here, and you don't need to escape
| the brackets.
Not only do they not need escaping, but doing so gives them different
meaning. From the procmailrc man page:
\< or \> Match the character before or after a word.
They are merely a shorthand for `[^a-zA-Z0-9_]',
but can also match newlines. Since they match
actual characters, they are only suitable to
delimit words, not to delimit inter-word space.
So they will match "<" and ">" as expected, but will also match much
more which might be unexpected.
| I've tested both of the following and they work:
|
| :0B:
| * Invalid recipient:.*<\/.*
|| echo $MATCH | sed 's/>.*//' >> blacklist
|
| :0:
| * B ?? Invalid recipient:.*<\/.*
|| echo $MATCH | sed 's/>.*//' >> blacklist
|
FWIW, this can be done without external programs (space and tab in two
character classes below).
NL="
"
:0
* B ?? ^Invalid recipient:[ ]*<?\/[^<> ]+
{
LOCKFILE=blacklist$LOCKEXT
xLOGILE=$LOGFILE
xVERBOSE=$VERBOSE
VERBOSE=no
LOGFILE=blacklist
LOG="$MATCH$NL"
LOCKFILE
LOGFILE=$xLOGILE
VERBOSE=$xVERBOSE
}
This assumes there is only one address, and there is only whitespace or
nothing between the colon and internet address (i.e.
user(_at_)host(_dot_)domain(_dot_)tld). The enclosing <> pair are optional.
This seems
to match the paramaters implied by the original message. If there is no
LOGFILE before this recipe, then assigning to xLOGFILE can be skipped
and "LOGFILE=$xLOGILE" replaced with "LOGFILE". If you know VERBOSE
will *always* =no coming in to this, the xVERBOSE stuff can be skipped
too. I'm not sure if the LOCKFILE is necessary either, or if some system
buffering will prevent corrupted writes. Whether any of this is worth
saving the extra processes is obviously in the "eye of the beholder".
--
/"\
Don Hammond \ / ASCII Ribbon Campaign
Raleigh, NC US X Against HTML Mail,
/ \ and News Too
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail