summaryrefslogtreecommitdiff
path: root/Mailman/app
diff options
context:
space:
mode:
authorBarry Warsaw2007-12-29 17:02:46 -0500
committerBarry Warsaw2007-12-29 17:02:46 -0500
commit68cce110887cc9fc46fd4c7798f3b8d893f1038f (patch)
tree8bd390bd78a2b22c5be19540eb7d7bee503c478b /Mailman/app
parent9124e1a17f439314b17206f2ad80f17d7b7971e8 (diff)
downloadmailman-68cce110887cc9fc46fd4c7798f3b8d893f1038f.tar.gz
mailman-68cce110887cc9fc46fd4c7798f3b8d893f1038f.tar.zst
mailman-68cce110887cc9fc46fd4c7798f3b8d893f1038f.zip
Port the implicit destination checking to the rules infrastructure and add a
bunch of doctests. Note that the old Hold Notification tests are temporarily disabled as these will have to be rewritten when the rule matching logic gets added.
Diffstat (limited to 'Mailman/app')
-rw-r--r--Mailman/app/bounces.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/Mailman/app/bounces.py b/Mailman/app/bounces.py
index 6df5c8aa6..7c3f6d894 100644
--- a/Mailman/app/bounces.py
+++ b/Mailman/app/bounces.py
@@ -19,7 +19,6 @@
__all__ = [
'bounce_message',
- 'has_explicit_destination',
'has_matching_bounce_header',
]
@@ -65,56 +64,6 @@ def bounce_message(mlist, msg, e=None):
-# Helper function used to match a pattern against an address.
-def _domatch(pattern, addr):
- try:
- 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, re.IGNORECASE):
- return True
- return False
-
-
-def has_explicit_destination(mlist, msg):
- """Does the list's name or an acceptable alias appear in the recipients?
-
- :param mlist: The mailing list the message is destined for.
- :param msg: The email message object.
- :return: True if the message is explicitly destined for the mailing list,
- otherwise False.
- """
- # Check all recipient addresses against the list's explicit addresses,
- # specifically To: Cc: and Resent-to:
- recipients = []
- to = []
- for header in ('to', 'cc', 'resent-to', 'resent-cc'):
- to.extend(getaddresses(msg.get_all(header, [])))
- for fullname, address in to:
- # 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 address is None or '@' not in address:
- continue
- address = address.lower()
- if address == mlist.posting_address:
- return True
- recipients.append(address)
- # Match the set of recipients against the list's acceptable aliases.
- aliases = mlist.acceptable_aliases.splitlines()
- for address in recipients:
- for alias in aliases:
- stripped = alias.strip()
- if not stripped:
- # Ignore blank or empty lines
- continue
- if domatch(stripped, address):
- return True
- return False
-
-
-
def _parse_matching_header_opt(mlist):
"""Return a list of triples [(field name, regex, line), ...]."""
# - Blank lines and lines with '#' as first char are skipped.