[Mailman-Users] header_filter_rules possible bug

Iain Pople ipople at unimelb.edu.au
Tue Aug 2 09:38:38 CEST 2005


I have noticed some unexpected behaviour with header_filter_rules.

I wanted to reject messages with an empty subject line so i came up  
with the following regex:


However it wasn't working as desired. After delving around in the  
SpamDetect.py code i noticed that the re.search call is not using  
MULTILINE mode. So the headers are treated as one long string and ^  
would only match the beginning of the string.

Is this the desired behaviour? To me it makes more sense that it  
should use multiline mode.


--- SpamDetect.py.bak   2005-08-02 15:56:42.083270000 +1000
+++ SpamDetect.py       2005-08-02 17:33:59.698226000 +1000
@@ -127,7 +127,7 @@
          for pattern in patterns.splitlines():
              if pattern.startswith('#'):
-            if re.search(pattern, headers, re.IGNORECASE):
+            if re.search(pattern, headers, re.IGNORECASE|re.MULTILINE):
                  if action == mm_cfg.DISCARD:
                      raise Errors.DiscardMessage
                  if action == mm_cfg.REJECT:
@@ -137,3 +137,4 @@
                      hold_for_approval(mlist, msg, msgdata,  
                  if action == mm_cfg.ACCEPT:

Iain Pople
Systems Programmer
University of Melbourne

More information about the Mailman-Users mailing list