diff options
| author | Barry Warsaw | 2010-09-20 17:28:00 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2010-09-20 17:28:00 -0400 |
| commit | 922b669dc02ceee78cf7a79860a4fcb977ab4634 (patch) | |
| tree | f6eeeb41d01dc34b0249392424a022db7b9a50a1 /src/mailman/rules/approved.py | |
| parent | d4019857e9765e18418b6ead23a4bbde4212ef39 (diff) | |
| download | mailman-922b669dc02ceee78cf7a79860a4fcb977ab4634.tar.gz mailman-922b669dc02ceee78cf7a79860a4fcb977ab4634.tar.zst mailman-922b669dc02ceee78cf7a79860a4fcb977ab4634.zip | |
Diffstat (limited to 'src/mailman/rules/approved.py')
| -rw-r--r-- | src/mailman/rules/approved.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/mailman/rules/approved.py b/src/mailman/rules/approved.py index f7e62c511..e4a92b0d2 100644 --- a/src/mailman/rules/approved.py +++ b/src/mailman/rules/approved.py @@ -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 @@ -66,7 +79,7 @@ class Approved: 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 +112,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 |
