~msapiro/mailman/topics

« back to all changes in this revision

Viewing changes to Mailman/Handlers/Approve.py

  • Committer: Mark Sapiro
  • Date: 2010-07-03 20:56:47 UTC
  • mfrom: (1006.3.2 2.2)
  • mto: (1006.1.254 2.2)
  • mto: This revision was merged to the branch mainline in revision 1022.
  • Revision ID: mark@msapiro.net-20100703205647-rdmmmctwensqq10v
Merged optional Sender: header feature from lp:~mss/mailman/2.2-sender-header.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
 
1
# Copyright (C) 1998-2010 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
43
43
 
44
44
def process(mlist, msg, msgdata):
45
45
    # Short circuits
46
 
    if msgdata.get('approved'):
 
46
    # Do not short circuit. The problem is SpamDetect comes before Approve.
 
47
    # Suppose a message with an Approved: header is held by SpamDetect (or
 
48
    # any other handler that might come before Approve) and then approved
 
49
    # by a moderator. When the approved message reaches Approve in the
 
50
    # pipeline, we still need to remove the Approved: (pseudo-)header, so
 
51
    # we can't short circuit.
 
52
    #if msgdata.get('approved'):
47
53
        # Digests, Usenet postings, and some other messages come pre-approved.
48
54
        # TBD: we may want to further filter Usenet messages, so the test
49
55
        # above may not be entirely correct.
50
 
        return
 
56
        #return
51
57
    # See if the message has an Approved or Approve header with a valid
52
58
    # list-moderator, list-admin.  Also look at the first non-whitespace line
53
59
    # in the file to see if it looks like an Approved header.  We are
55
61
    # because we want to discourage the practice of sending the site admin
56
62
    # password through email in the clear.
57
63
    missing = []
58
 
    passwd = msg.get('approved', msg.get('approve', missing))
 
64
    for hdr in ('approved', 'approve', 'x-approved', 'x-approve'):
 
65
        passwd = msg.get(hdr, missing)
 
66
        if passwd is not missing:
 
67
            break
59
68
    if passwd is missing:
60
69
        # Find the first text/plain part in the message
61
70
        part = None
74
83
            if i >= 0:
75
84
                name = line[:i]
76
85
                value = line[i+1:]
77
 
                if name.lower() in ('approve', 'approved'):
 
86
                if name.lower() in ('approve',
 
87
                                    'approved',
 
88
                                    'x-approve',
 
89
                                    'x-approved',
 
90
                                    ):
78
91
                    passwd = value.lstrip()
79
92
                    # Now strip the first line from the payload so the
80
93
                    # password doesn't leak.
98
111
            # line of HTML or other fancy text may include additional message
99
112
            # text.  This pattern works with HTML.  It may not work with rtf
100
113
            # or whatever else is possible.
101
 
            pattern = name + ':(\s| )*' + re.escape(passwd)
 
114
            pattern = name + ':(\xA0|\s| )*' + re.escape(passwd)
102
115
            for part in typed_subpart_iterator(msg, 'text'):
103
116
                if part is not None and part.get_payload() is not None:
104
117
                    lines = part.get_payload(decode=True)