summaryrefslogtreecommitdiff
path: root/src/mailman/rules/approved.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/rules/approved.py')
-rw-r--r--src/mailman/rules/approved.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/mailman/rules/approved.py b/src/mailman/rules/approved.py
index f7e62c511..51314cc02 100644
--- a/src/mailman/rules/approved.py
+++ b/src/mailman/rules/approved.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2010 by the Free Software Foundation, Inc.
+# Copyright (C) 2007-2011 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
@@ -34,6 +34,12 @@ from mailman.interfaces.rules import IRule
EMPTYSTRING = ''
+HEADERS = [
+ 'approve',
+ 'approved',
+ 'x-approve',
+ 'x-approved',
+ ]
@@ -45,13 +51,20 @@ class Approved:
description = _('The message has a matching Approve or Approved header.')
record = True
+ def _get_password(self, msg, missing):
+ for header in HEADERS:
+ password = msg.get(header, missing)
+ if password is not missing:
+ return password
+ return missing
+
def check(self, mlist, msg, msgdata):
"""See `IRule`."""
# See if the message has an Approved or Approve header with a valid
# moderator password. Also look at the first non-whitespace line in
# the file to see if it looks like an Approved header.
missing = object()
- password = msg.get('approved', msg.get('approve', missing))
+ password = self._get_password(msg, missing)
if password is missing:
# Find the first text/plain part in the message
part = None
@@ -60,13 +73,14 @@ class Approved:
break
payload = part.get_payload(decode=True)
if payload is not None:
+ line = ''
lines = payload.splitlines(True)
for lineno, line in enumerate(lines):
if line.strip() <> '':
break
if ':' in line:
header, value = line.split(':', 1)
- if header.lower() in ('approved', 'approve'):
+ if header.lower() in HEADERS:
password = value.strip()
# Now strip the first line from the payload so the
# password doesn't leak.
@@ -99,8 +113,8 @@ class Approved:
if re.search(pattern, payload):
reset_payload(part, re.sub(pattern, '', payload))
else:
- del msg['approved']
- del msg['approve']
+ for header in HEADERS:
+ del msg[header]
return password is not missing and password == mlist.moderator_password