procmail
[Top] [All Lists]

Re: What am I doing wrong?

2000-10-24 07:28:24
Martin wrote,

: initialize the scoring:

: * 0^0

Oy.  Mad Duck, you truly are,
 
: (greetings from the heart of the sun)

and you've been in the sun too long.  The score always begins at 0 for each
recipe, and if you want to import an earlier score, you need to include it
explicitly by referring to $= or a regular variable in which you had pre-
viously stored $=.  Besides, if the score were carried over from recipe to
recipe, adding zero would not clear it out.

Dallman was close:

|       :0 c:
|       * 1^0 ^Subject:.*password
|       * 1^0 B ?? password
|       passwords

That will work, but better yet, if a match is found in the subject, procmail
shouldn't waste the effort of searching the body:

   :0c:
   * ^9876543210^0 ^Subject:.*password
   * 1^0 B ?? password
   passwords

or one can do a reverse DeMorgan for ORing:

   :0
   * ! ^Subject:.*password
   * ! B ?? password
   { }
   :0Ec:
   passwords

Dallman's concern here,

| We still might find the phrase "Subject: not about passwords!"
| left-anchored in either the header area *or* the body area; but let's not
| worry about that.  Much more dangerous would have been a body egrep
| that would have been content to match on a non-anchored occurrence of
| "subject" and "password" in the same line, as, for example,

|   and my Aunt Matilda always made the mistake of listening to 
|   her subjective emotional state when trying to remember passwords.

doesn't bother me, as I'm sure Robert meant "password" as a substitute for an
actual password, not as the literal word "password," and that the real pass-
word is some silly combination of characters that won't show up in meaningful
text.  (Besides, Robert's original code didn't even search the body.)

In any case, Dallman saw the problem.  Robert's original syntax was searching
for the regexp "subject.*password" or "body.*password" in the headers: he
wasn't using a `B' flag nor left-anchoring them.

Finally, there's a way to match on text in subject or body but not in any
other header fields in a single condition.  It's rather nasty, though:

  :0HBc:
  * ^^(.+$)*(Subject:|$(.*$)*).*password
  passwords

and it's both harder to read and probably less efficient than two properly
ORed conditions.  (By "properly" I mean such that a hit on the first skips
testing the second.)


_______________________________________________
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>