diff options
| author | Barry Warsaw | 2009-02-23 14:13:32 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-02-23 14:13:32 -0500 |
| commit | b6ed8a7c98ea02af9014793f3b508c601da6ea75 (patch) | |
| tree | e0748f60a06bb54493624b031d0ac10b90cabd00 /src/mailman/rules | |
| parent | 2d2d5393acc7db23baf4f3d43a0712bfa795c03e (diff) | |
| download | mailman-b6ed8a7c98ea02af9014793f3b508c601da6ea75.tar.gz mailman-b6ed8a7c98ea02af9014793f3b508c601da6ea75.tar.zst mailman-b6ed8a7c98ea02af9014793f3b508c601da6ea75.zip | |
acceptable_aliases are no longer a pickle.
Diffstat (limited to 'src/mailman/rules')
| -rw-r--r-- | src/mailman/rules/docs/implicit-dest.txt | 54 | ||||
| -rw-r--r-- | src/mailman/rules/implicit_dest.py | 9 |
2 files changed, 50 insertions, 13 deletions
diff --git a/src/mailman/rules/docs/implicit-dest.txt b/src/mailman/rules/docs/implicit-dest.txt index e5c340dcd..c0439cfca 100644 --- a/src/mailman/rules/docs/implicit-dest.txt +++ b/src/mailman/rules/docs/implicit-dest.txt @@ -4,16 +4,17 @@ Implicit destination The 'implicit-dest' rule matches when the mailing list's posting address is not explicitly mentioned in the set of message recipients. - >>> mlist = config.db.list_manager.create(u'_xtest@example.com') + >>> mlist = create_list(u'_xtest@example.com') >>> rule = config.rules['implicit-dest'] >>> print rule.name implicit-dest -This rule matches messages that have implicit destination, meaning that the +This rule matches messages that have an implicit destination, meaning that the mailing list's posting address isn't included in the explicit recipients. >>> mlist.require_explicit_destination = True - >>> mlist.acceptable_aliases = u'' + >>> mlist.clear_acceptable_aliases() + >>> msg = message_from_string("""\ ... From: aperson@example.org ... Subject: An implicit message @@ -48,7 +49,8 @@ then the rule will not match. >>> del msg['cc'] >>> rule.check(mlist, msg, {}) True - >>> mlist.acceptable_aliases = u'myfriend@example.com' + + >>> mlist.add_acceptable_alias(u'myfriend@example.com') >>> rule.check(mlist, msg, {}) False @@ -56,9 +58,36 @@ A message gated from NNTP will obviously have an implicit destination. Such gated messages will not be held for implicit destination because it's assumed that Mailman pulled it from the appropriate news group. - >>> rule.check(mlist, msg, dict(fromusenet=True)) + >>> rule.check(mlist, msg, dict(from_usenet=True)) + False + +Additional aliases can be added. + + >>> mlist.add_acceptable_alias(u'other@example.com') + >>> del msg['to'] + >>> rule.check(mlist, msg, {}) + True + + >>> msg['To'] = 'other@example.com' + >>> rule.check(mlist, msg, {}) + False + +Aliases can be removed. + + >>> mlist.remove_acceptable_alias(u'other@example.com') + >>> rule.check(mlist, msg, {}) + True + +Aliases can also be cleared. + + >>> msg['Cc'] = u'myfriend@example.com' + >>> rule.check(mlist, msg, {}) False + >>> mlist.clear_acceptable_aliases() + >>> rule.check(mlist, msg, {}) + True + Alias patterns -------------- @@ -67,9 +96,22 @@ It's also possible to specify an alias pattern, i.e. a regular expression to match against the recipients. For example, we can say that if there is a recipient in the example.net domain, then the rule does not match. - >>> mlist.acceptable_aliases = u'^.*@example.net' + >>> mlist.add_acceptable_alias(u'^.*@example.net') >>> rule.check(mlist, msg, {}) True + >>> msg['To'] = 'you@example.net' >>> rule.check(mlist, msg, {}) False + + +Bad aliases +----------- + +You cannot add an alias that looks like neither a pattern nor an email +address. + + >>> mlist.add_acceptable_alias('foobar') + Traceback (most recent call last): + ... + ValueError: foobar diff --git a/src/mailman/rules/implicit_dest.py b/src/mailman/rules/implicit_dest.py index 3ddffa2cf..69e6f8434 100644 --- a/src/mailman/rules/implicit_dest.py +++ b/src/mailman/rules/implicit_dest.py @@ -55,16 +55,11 @@ class ImplicitDestination: # a caret (i.e. ^), then it's a regular expression to match against. aliases = set() alias_patterns = set() - for alias in mlist.acceptable_aliases.splitlines(): - alias = alias.strip().lower() + for alias in mlist.acceptable_aliases: if alias.startswith('^'): alias_patterns.add(alias) - elif '@' in alias: - aliases.add(alias) else: - # This is not a regular expression, nor a fully-qualified - # email address, so skip it. - pass + aliases.add(alias) # Add the list's posting address, i.e. the explicit address, to the # set of acceptable aliases. aliases.add(mlist.posting_address) |
