procmail
[Top] [All Lists]

Re: Capture match to variable?

2001-06-15 07:17:48
James Ervin, wanting to use a backreference from a regexp, writes:
| [...]
| 
| What I really want to do is something like this:
| 
| :0BH
|   * ^Content-(Type|Disposition):.*name=.*\.(exe|com|zip|vbs|shs|hta|scr|chm)
|    *! ^From(_dot_)*knowngoodaddress(_at_)mydomain(_dot_)com
|   {
|       :0f
|         | formail -I "X-VIRUSWARNING: This file had a $2 attachment"
|       :0:
|       ! suspectfiles(_at_)mydomain(_dot_)com
|   }
| 

What you want is procmail's MATCH operator: "\/".  When inserted in a
regular expression, everything following the the operator is assigned to
the $MATCH variable. So two changes are requred to your recipe above.
Insert \/ before the \. of the filename extension:

* ^Content-(Type|Disposition):.*name=.*\/\.(exe|com|zip|vbs|shs|hta|scr|chm)

And then use $MATCH when inserting the custom header:

| formail -I "X-VIRUSWARNING: This file had a $MATCH attachment"



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