CVS: tmda/TMDA FilterParser.py,1.64,1.65

"Jason R. Mastaler" <[email protected]> Thu, 19 Feb 2004 10:42:04 -0800
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda/TMDA
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23297/TMDA

Modified Files:
	FilterParser.py 
Log Message:
New feature from David Bremner.  Add 'shell=' and 'python=' tag
actions to the outgoing filter.

This allows you to add dynamic/shell escaped headers from the outgoing
filter file (think per-recipient, or with '*' at the end for all
recipients).

This differs from the ADDED_HEADERS_CLIENT feature in that the headers
can be added selectively per-recipient or to all recipients with '*'
at the end, rather than only to all recipients.  Also, you have access
to the message recipient address in the $TMDA_RECIPIENT variable.  An
example:

# Add X-Hashcash headers
to * tag 
   x-hashcash shell="hashcash -q -m -b20 ${TMDA_RECIPIENT}"

The python= feature is incomplete at this time.  Also, I refrain from
documenting these features until they are complete.


Index: FilterParser.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/FilterParser.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- FilterParser.py	30 Jan 2004 07:29:42 -0000	1.64
+++ FilterParser.py	19 Feb 2004 18:42:01 -0000	1.65
@@ -238,12 +238,15 @@
     """, re.VERBOSE)
         
     tag_action = re.compile(r"""
-    ( [A-Za-z][-\w]+ )
-    \s+
-    (?: ([\'\"]) ( (?: \\\2 | . )+? ) \2
-    | ( \S+ ) )
+    ( [A-Za-z][-\w]+ ) 
+    \s+ 
+    (\w+\s*=\s*)?
+    (?: 
+    ([\'\"]) ( (?: \\\3 | . )+? ) \3
+    | ( \S+ ) 
+    )
     """, re.VERBOSE)
-
+    
     in_action = re.compile(r"""
     ( drop | exit | stop
     | hold
@@ -252,7 +255,7 @@
     
     out_action = re.compile(r"""
     ( (?:(?:bare|sender|domain|dated)(?:=\S+)?)
-    | (?:(?:exp(?:licit)?|as|ext(?:ension)?|kw|keyword)=\S+)
+    | (?:(?:exp(?:licit)?|as|ext(?:ension)?|kw|keyword|shell|python)=\S+)
     | default )""", re.VERBOSE | re.IGNORECASE)
     
     arg_option = re.compile(r'(\w+)(=?)')
@@ -649,8 +652,8 @@
                     errstr = '"%s": ' % source
                     errstr += 'malformed header field or missing <action>'
                     raise Error, errstr
-		header = string.lower(mo.group(1))
-		action = mo.group(3) or mo.group(4)
+                header = string.lower(mo.group(1))
+                action = (mo.group(2) or "") + (mo.group(4) or mo.group(5))
                 if action:
                     if not actions:
                         actions = {}