procmail
[Top] [All Lists]

Re: Help adding To: and CC: to message body

2004-10-14 16:15:05
On Thu, Oct 14, 2004 at 05:49:09PM -0500, David W. Tamkin wrote:
Christopher has this code


# Capture the To line and put it in TOWHO
:0
* ^To:\/.*
{ TOWHO=$MATCH }

# Capture the CC line and put it in CCWHO
:0
* ^CC:\/.*
{ CCWHO=$MATCH }

and Dallman said,

One point here: you will want to claer the $MATCH var before each of
these.  Otherwise, e.g., if there is a blank To: or Cc: line, you
will assign the previous value of $MATCH to your var.

If there's an empty To: or Cc: line, MATCH will be empty and thus so 
will the variable.  If there's no To: or no Cc:, the condition will 
fail, procmail won't enter the respective set of braces, and the 
respective variable will not be assigned.  There's no way for the 
previous value of MATCH to get into TOWHOM or CCWHOM.

No, you misunderstood me.  I'm saying he might have had MATCH set
from a previous recipe in his .procmailrc.  Then he gets to a message
with a blank To: or Cc: line and has that value injected here.


If any variables should be cleared ahead of that code, it's TOWHOM and 
CCWHOM, in case To: or Cc: respectively is not present.

I'm all for clearing vars, but this seems not likely to be a problem.
What are the odds that TOWHO(M)/CCWHO(M) happened to be set by something
else?  Sure, go ahead and clear 'em first, but it's more likely to cause
problems not to clear MATCH.

-- 
dman

____________________________________________________________
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

<Prev in Thread] Current Thread [Next in Thread>