diff options
author | Mark Sapiro <mark@msapiro.net> | 2015-10-15 21:06:52 -0700 |
---|---|---|
committer | Mark Sapiro <mark@msapiro.net> | 2015-10-15 21:06:52 -0700 |
commit | ac9886b17e0462f70209cc2ee0bc3744dd9bd520 (patch) | |
tree | 762c9e8849d860f2911ab5e2031cb9db90c32128 /Mailman/Handlers/Moderate.py | |
parent | b7f4af5909c45a4084174d6b5a4c3ea9742fd997 (diff) | |
download | mailman2-ac9886b17e0462f70209cc2ee0bc3744dd9bd520.tar.gz mailman2-ac9886b17e0462f70209cc2ee0bc3744dd9bd520.tar.xz mailman2-ac9886b17e0462f70209cc2ee0bc3744dd9bd520.zip |
Refactored the GetPattern list method to simplify extending @listname
syntax to new attributes in the future. Changed Moderate.py to use the
GetPattern method to process the *_these_nonmembers lists.
Diffstat (limited to 'Mailman/Handlers/Moderate.py')
-rw-r--r-- | Mailman/Handlers/Moderate.py | 57 |
1 files changed, 16 insertions, 41 deletions
diff --git a/Mailman/Handlers/Moderate.py b/Mailman/Handlers/Moderate.py index dfc2c567..49ed1d7e 100644 --- a/Mailman/Handlers/Moderate.py +++ b/Mailman/Handlers/Moderate.py @@ -97,15 +97,27 @@ def process(mlist, msg, msgdata): sender = msg.get_sender() # From here on out, we're dealing with non-members. listname = mlist.internal_name() - if matches_p(sender, mlist.accept_these_nonmembers, listname): + if mlist.GetPattern(sender, + mlist.accept_these_nonmembers, + at_list='accept_these_nonmembers' + ): return - if matches_p(sender, mlist.hold_these_nonmembers, listname): + if mlist.GetPattern(sender, + mlist.hold_these_nonmembers, + at_list='hold_these_nonmembers' + ): Hold.hold_for_approval(mlist, msg, msgdata, Hold.NonMemberPost) # No return - if matches_p(sender, mlist.reject_these_nonmembers, listname): + if mlist.GetPattern(sender, + mlist.reject_these_nonmembers, + at_list='reject_these_nonmembers' + ): do_reject(mlist) # No return - if matches_p(sender, mlist.discard_these_nonmembers, listname): + if mlist.GetPattern(sender, + mlist.discard_these_nonmembers, + at_list='discard_these_nonmembers' + ): do_discard(mlist, msg) # No return # Okay, so the sender wasn't specified explicitly by any of the non-member @@ -124,43 +136,6 @@ def process(mlist, msg, msgdata): -def matches_p(sender, nonmembers, listname): - # First strip out all the regular expressions and listnames - plainaddrs = [addr for addr in nonmembers if not (addr.startswith('^') - or addr.startswith('@'))] - addrdict = Utils.List2Dict(plainaddrs, foldcase=1) - if addrdict.has_key(sender): - return 1 - # Now do the regular expression matches - for are in nonmembers: - if are.startswith('^'): - try: - cre = re.compile(are, re.IGNORECASE) - except re.error: - continue - if cre.search(sender): - return 1 - elif are.startswith('@'): - # XXX Needs to be reviewed for list@domain names. - try: - mname = are[1:].lower().strip() - if mname == listname: - # don't reference your own list - syslog('error', - '*_these_nonmembers in %s references own list', - listname) - else: - mother = MailList(mname, lock=0) - if mother.isMember(sender): - return 1 - except Errors.MMUnknownListError: - syslog('error', - '*_these_nonmembers in %s references non-existent list %s', - listname, mname) - return 0 - - - def do_reject(mlist): listowner = mlist.GetOwnerEmail() if mlist.nonmember_rejection_notice: |