procmail
[Top] [All Lists]

Re: Procmail is over-matching my expression

2005-02-25 03:55:03
Toen wij Justin Gombos kietelden, kwam er dit uit:

  From someone-else
  To: <disposable(_dot_)address(_dot_)jgombos(_at_)spamgourmet(_dot_)com>

  This is a placeholder for a body.

Here is the (simplified) script that is screwing up:

  MAILDIR=./

As Sean said, put an absolute path in there. And MAILDIR 
should never (for most kinds of never) end in a slash.
When testing, a value of just a dot is fine.

  DEFAULT=$MAILDIR/not_from_self

   DEFAULT = "$MAILDIR/not_from_self"

(and change MAILDIR, because DEFAULT now contains a '//')


  LOGFILE=$MAILDIR/results.log

Same //-problenm.

  VERBOSE=1

  FROM_ = "(From[ ]|(Old-|X-)?(Resent-)?\
  (From|Reply-To|Sender):)(.*\<)?"

The name FROM_ is 'reserved' by a lot of procmail-coders 
to hold (the value from) the From_line. Allways name variables 
holding regexes in a special way.

   RE_FROM = '(From[ ]|(Old-|X-)?\
              (Resent-)?(From|Reply-To|Sender):(.*\<)?)'

I indented, so used single-quotes. And I moved a ')' to the end, 
since the (.*\<)? does not belong after From[ ]. I am tempted to 
take the whole (.*\<)? thing out of it, because a \/ might be 
needed.


  SG_ACCOUNT = jgombos(_at_)spamgourmet(_dot_)com

  SG_ADDRESS = [^.]+[.][^.]+[.]$SG_ACCOUNT

Escape the dot in SG_ACCOUNT, or use $\S_ACCOUNT.
The [^.] is overly broad, it will also match a '<', so put only the 
characters there that you choose to use for those extra parts.

   SG_ACCOUNT    = 'jgombos(_at_)spamgourmet(_dot_)com'
   RE_SG_PART    = '[a-z0-9]+'
   RE_SG_ADDRESS = "${RE_SG_PART}[.]${RE_SG_PART}[.]$\SG_ACCOUNT"


  :0 :
  *$ ^${FROM_}${SG_ADDRESS}
  from_self

As Sean showed, you got bitten by the "\< includes newline" feature. 
Use \/ to see what actually was matched, and to match greedy 
from the right.

   SG_ACCOUNT    = 'jgombos(_at_)spamgourmet(_dot_)com'
   RE_SG_PART    = '[a-z0-9]+'
   RE_SG_ADDRESS = "${RE_SG_PART}[.]${RE_SG_PART}[.]$\SG_ACCOUNT"
   RE_FROM       = '(From[ ]|(Old-|X-)?\
                     (Resent-)?(From|Reply-To|Sender):.*)'

   MSG = 'From someone-else
Reply-To: <disposable(_dot_)address(_dot_)jgombos(_at_)spamgourmet(_dot_)com>'

   :0
   *$ MSG ?? ^${RE_FROM}\/${RE_SG_ADDRESS}
   { from_self = 'T' }

or (while testing)

   :0
   *$    1^1 MSG ?? ^^From \/${RE_SG_ADDRESS}
   *$   10^1 MSG ?? ^(Old-|X-)?(Resent-)?From:.*\/${RE_SG_ADDRESS}
   *$  100^1 MSG ?? ^(Old-|X-)?(Resent-)?Reply-To:.*\/${RE_SG_ADDRESS}
   *$ 1000^1 MSG ?? ^(Old-|X-)?(Resent-)?Sender:.*\/${RE_SG_ADDRESS}
   { from_self = 'T' }


-- 
Grtz, Ruud

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail