summaryrefslogtreecommitdiff
path: root/Mailman/pipeline/cleanse.py
diff options
context:
space:
mode:
authorBarry Warsaw2008-02-17 17:34:21 -0500
committerBarry Warsaw2008-02-17 17:34:21 -0500
commit69d158b13ae9cfa37040c2e7a664ca266b42050b (patch)
tree07f48ee990b6bab514f86199eaa250a04280120c /Mailman/pipeline/cleanse.py
parentb36de8a6a5b84021c003b728274f7e9e95861c9d (diff)
downloadmailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.tar.gz
mailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.tar.zst
mailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.zip
Diffstat (limited to 'Mailman/pipeline/cleanse.py')
-rw-r--r--Mailman/pipeline/cleanse.py71
1 files changed, 42 insertions, 29 deletions
diff --git a/Mailman/pipeline/cleanse.py b/Mailman/pipeline/cleanse.py
index 24e1af340..dad6e9127 100644
--- a/Mailman/pipeline/cleanse.py
+++ b/Mailman/pipeline/cleanse.py
@@ -17,42 +17,55 @@
"""Cleanse certain headers from all messages."""
+__metaclass__ = type
+__all__ = ['Cleanse']
+
+
import logging
from email.Utils import formataddr
+from zope.interface import implements
+from Mailman.i18n import _
+from Mailman.interfaces import IHandler
from Mailman.pipeline.cook_headers import uheader
+
log = logging.getLogger('mailman.post')
-def process(mlist, msg, msgdata):
- # Always remove this header from any outgoing messages. Be sure to do
- # this after the information on the header is actually used, but before a
- # permanent record of the header is saved.
- del msg['approved']
- # Remove this one too.
- del msg['approve']
- # Also remove this header since it can contain a password
- del msg['urgent']
- # We remove other headers from anonymous lists
- if mlist.anonymous_list:
- log.info('post to %s from %s anonymized',
- mlist.fqdn_listname, msg.get('from'))
- del msg['from']
- del msg['reply-to']
- del msg['sender']
- # Hotmail sets this one
- del msg['x-originating-email']
- i18ndesc = str(uheader(mlist, mlist.description, 'From'))
- msg['From'] = formataddr((i18ndesc, mlist.posting_address))
- msg['Reply-To'] = mlist.posting_address
- # Some headers can be used to fish for membership
- del msg['return-receipt-to']
- del msg['disposition-notification-to']
- del msg['x-confirm-reading-to']
- # Pegasus mail uses this one... sigh
- del msg['x-pmrqc']
- # Don't let this header be spoofed. See RFC 5064.
- del msg['archived-at']
+class Cleanse:
+ """Cleanse certain headers from all messages."""
+
+ implements(IHandler)
+
+ name = 'cleanse'
+ description = _('Cleanse certain headers from all messages.')
+
+ def process(self, mlist, msg, msgdata):
+ """See `IHandler`."""
+ # Remove headers that could contain passwords.
+ del msg['approved']
+ del msg['approve']
+ del msg['urgent']
+ # We remove other headers from anonymous lists.
+ if mlist.anonymous_list:
+ log.info('post to %s from %s anonymized',
+ mlist.fqdn_listname, msg.get('from'))
+ del msg['from']
+ del msg['reply-to']
+ del msg['sender']
+ # Hotmail sets this one
+ del msg['x-originating-email']
+ i18ndesc = str(uheader(mlist, mlist.description, 'From'))
+ msg['From'] = formataddr((i18ndesc, mlist.posting_address))
+ msg['Reply-To'] = mlist.posting_address
+ # Some headers can be used to fish for membership.
+ del msg['return-receipt-to']
+ del msg['disposition-notification-to']
+ del msg['x-confirm-reading-to']
+ # Pegasus mail uses this one... sigh.
+ del msg['x-pmrqc']
+ # Don't let this header be spoofed. See RFC 5064.
+ del msg['archived-at']