~msapiro/mailman/topics

« back to all changes in this revision

Viewing changes to Mailman/Handlers/Moderate.py

  • Committer: Mark Sapiro
  • Date: 2014-12-03 23:47:23 UTC
  • mfrom: (1006.1.356 2.2)
  • Revision ID: mark@msapiro.net-20141203234723-3pcwx85xua4n84yx
Merged the 2.2 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2001-2008 by the Free Software Foundation, Inc.
 
1
# Copyright (C) 2001-2014 by the Free Software Foundation, Inc.
2
2
#
3
3
# This program is free software; you can redistribute it and/or
4
4
# modify it under the terms of the GNU General Public License
21
21
import re
22
22
from email.MIMEMessage import MIMEMessage
23
23
from email.MIMEText import MIMEText
 
24
from email.Utils import parseaddr
24
25
 
25
26
from Mailman import mm_cfg
26
27
from Mailman import Utils
47
48
 
48
49
 
49
50
def process(mlist, msg, msgdata):
50
 
    if msgdata.get('approved') or msgdata.get('fromusenet'):
 
51
    if msgdata.get('approved'):
51
52
        return
52
 
    # First of all, is the poster a member or not?
 
53
    # Is the poster a member or not?
53
54
    for sender in msg.get_senders():
54
55
        if mlist.isMember(sender):
55
56
            break
105
106
    # moderation configuration variables.  Handle by way of generic non-member
106
107
    # action.
107
108
    assert 0 <= mlist.generic_nonmember_action <= 4
108
 
    if mlist.generic_nonmember_action == 0:
 
109
    if mlist.generic_nonmember_action == 0 or msgdata.get('fromusenet'):
109
110
        # Accept
110
111
        return
111
112
    elif mlist.generic_nonmember_action == 1:
136
137
        elif are.startswith('@'):
137
138
            # XXX Needs to be reviewed for list@domain names.
138
139
            try:
139
 
                if are[1:] == listname:
 
140
                mname = are[1:].lower().strip()
 
141
                if mname == listname:
140
142
                    # don't reference your own list
141
143
                    syslog('error',
142
144
                        '*_these_nonmembers in %s references own list',
143
145
                        listname)
144
146
                else:
145
 
                    mother = MailList(are[1:], lock=0)
 
147
                    mother = MailList(mname, lock=0)
146
148
                    if mother.isMember(sender):
147
149
                        return 1
148
150
            except Errors.MMUnknownListError:
149
151
                syslog('error',
150
152
                  '*_these_nonmembers in %s references non-existent list %s',
151
 
                  listname, are[1:])
 
153
                  listname, mname)
152
154
    return 0
153
155
 
154
156