aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbwarsaw <>2005-01-30 18:36:26 +0000
committerbwarsaw <>2005-01-30 18:36:26 +0000
commitb8b31d48ac28829a95d81e158ab43d202d05a021 (patch)
treee9a135ed5dbbfc20afad860ac6aacbd4776a8737
parentba07f5b08edf3c188f6063c8214a7e71ff758c2e (diff)
downloadmailman2-b8b31d48ac28829a95d81e158ab43d202d05a021.tar.gz
mailman2-b8b31d48ac28829a95d81e158ab43d202d05a021.tar.xz
mailman2-b8b31d48ac28829a95d81e158ab43d202d05a021.zip
HasExplicitDest(): Resolution of SF bug #1112349. acceptable_aliases should
be matched case insensitively. Also include a bunch of formatting cleanups.
Diffstat (limited to '')
-rw-r--r--Mailman/MailList.py44
1 files changed, 21 insertions, 23 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 23967770..0c937eb3 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2004 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -1303,20 +1303,19 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
#
def HasExplicitDest(self, msg):
"""True if list name or any acceptable_alias is included among the
- to or cc addrs."""
- # BAW: fall back to Utils.ParseAddr if the first test fails.
- # this is the list's full address
+ addresses in the recipient headers.
+ """
+ # This is the list's full address.
listfullname = '%s@%s' % (self.internal_name(), self.host_name)
recips = []
- # check all recipient addresses against the list's explicit addresses,
+ # Check all recipient addresses against the list's explicit addresses,
# specifically To: Cc: and Resent-to:
to = []
for header in ('to', 'cc', 'resent-to', 'resent-cc'):
to.extend(getaddresses(msg.get_all(header, [])))
for fullname, addr in to:
- # It's possible that if the header doesn't have a valid
- # (i.e. RFC822) value, we'll get None for the address. So skip
- # it.
+ # It's possible that if the header doesn't have a valid RFC 2822
+ # value, we'll get None for the address. So skip it.
if addr is None:
continue
addr = addr.lower()
@@ -1325,40 +1324,39 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
localpart == self.internal_name() or
# exact match against the complete list address
addr == listfullname):
- return 1
+ return True
recips.append((addr, localpart))
- #
- # helper function used to match a pattern against an address. Do it
+ # Helper function used to match a pattern against an address.
def domatch(pattern, addr):
try:
- if re.match(pattern, addr):
- return 1
+ if re.match(pattern, addr, re.IGNORECASE):
+ return True
except re.error:
# The pattern is a malformed regexp -- try matching safely,
# with all non-alphanumerics backslashed:
- if re.match(re.escape(pattern), addr):
- return 1
- #
+ if re.match(re.escape(pattern), addr, re.IGNORECASE):
+ return True
+ return False
# Here's the current algorithm for matching acceptable_aliases:
#
# 1. If the pattern does not have an `@' in it, we first try matching
# it against just the localpart. This was the behavior prior to
- # 2.0beta3, and is kept for backwards compatibility.
- # (deprecated).
+ # 2.0beta3, and is kept for backwards compatibility. (deprecated).
#
# 2. If that match fails, or the pattern does have an `@' in it, we
# try matching against the entire recip address.
+ aliases = self.acceptable_aliases.splitlines()
for addr, localpart in recips:
- for alias in self.acceptable_aliases.split('\n'):
+ for alias in aliases:
stripped = alias.strip()
if not stripped:
- # ignore blank or empty lines
+ # Ignore blank or empty lines
continue
if '@' not in stripped and domatch(stripped, localpart):
- return 1
+ return True
if domatch(stripped, addr):
- return 1
- return 0
+ return True
+ return False
def parse_matching_header_opt(self):
"""Return a list of triples [(field name, regex, line), ...]."""