Update of /cvsroot/mailman/mailman/Mailman/Handlers
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15990/Mailman/Handlers
Modified Files:
Approve.py Cleanse.py CookHeaders.py Decorate.py MimeDel.py
SMTPDirect.py Scrubber.py SpamDetect.py ToArchive.py
ToDigest.py
Log Message:
Port cleaning changes forward from 2.1-maint branch.
Index: Approve.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/Approve.py,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -d -r2.14 -r2.15
--- Approve.py 21 Dec 2005 02:53:09 -0000 2.14
+++ Approve.py 30 Dec 2005 18:56:46 -0000 2.15
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Determine whether the message is approved for delivery.
@@ -74,22 +75,22 @@
part.set_payload(NL.join(lines))
stripped = True
if stripped:
- # MAS: Bug 1181161 - Now try all the text parts in case
- # it's multipart/alternative with the approved line in
- # HTML or other text part. We make a pattern from the
- # approved line and delete it from all text/* parts in
- # which we find it. It would be better to just iterate
- # forward, but email compatability for pre Python 2.2
- # returns a list, not a true iterator.
- # This will process all the multipart/alternative parts
- # in the message as well as all other text parts. We
- # shouldn't find the pattern outside the mp/a parts, but
- # if we do, it is probably best to delete it anyway as it
- # does contain the password.
- # Make a pattern to delete. We can't just delete a line
- # because line of HTML or other fancy text may include
- # additional message text. This pattern works with HTML.
- # It may not work with rtf or whatever else is possible.
+ # MAS: Bug 1181161 - Now try all the text parts in case it's
+ # multipart/alternative with the approved line in HTML or other
+ # text part. We make a pattern from the Approved line and delete
+ # it from all text/* parts in which we find it. It would be
+ # better to just iterate forward, but email compatability for pre
+ # Python 2.2 returns a list, not a true iterator.
+ #
+ # This will process all the multipart/alternative parts in the
+ # message as well as all other text parts. We shouldn't find the
+ # pattern outside the mp/a parts, but if we do, it is probably
+ # best to delete it anyway as it does contain the password.
+ #
+ # Make a pattern to delete. We can't just delete a line because
+ # line of HTML or other fancy text may include additional message
+ # text. This pattern works with HTML. It may not work with rtf
+ # or whatever else is possible.
pattern = name + ':(\s| )*' + re.escape(passwd)
for part in typed_subpart_iterator(msg, 'text'):
if part is not None and part.get_payload() is not None:
Index: Cleanse.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/Cleanse.py,v
retrieving revision 2.10
retrieving revision 2.11
diff -u -d -r2.10 -r2.11
--- Cleanse.py 13 Nov 2005 02:42:54 -0000 2.10
+++ Cleanse.py 30 Dec 2005 18:56:46 -0000 2.11
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Cleanse certain headers from all messages."""
Index: CookHeaders.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/CookHeaders.py,v
retrieving revision 2.42
retrieving revision 2.43
diff -u -d -r2.42 -r2.43
--- CookHeaders.py 26 Dec 2005 07:24:02 -0000 2.42
+++ CookHeaders.py 30 Dec 2005 18:56:46 -0000 2.43
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Cook a message's Subject header."""
@@ -247,16 +248,16 @@
if len(lines) > 1 and lines[1] and lines[1][0] in ' \t':
ws = lines[1][0]
msgdata['origsubj'] = subject
- # The subject may be multilingual but we take the first charset
- # as major one and try to decode. If it is decodable, returned
- # subject is in one line and cset is properly set. If fail,
- # subject is mime-encoded and cset is set as us-ascii. See detail
- # for ch_oneline() (CookHeaders one line function).
+ # The subject may be multilingual but we take the first charset as major
+ # one and try to decode. If it is decodable, returned subject is in one
+ # line and cset is properly set. If fail, subject is mime-encoded and
+ # cset is set as us-ascii. See detail for ch_oneline() (CookHeaders one
+ # line function).
subject, cset = ch_oneline(subject)
- # TK: Python interpreter has eveolved to be strict on ascii charset
- # code range. It is safe to use unicode string when manupilating
- # header contents with re module. It would be best to return unicode
- # in ch_oneline() but here is temporary solution.
+ # TK: Python interpreter has evolved to be strict on ascii charset code
+ # range. It is safe to use unicode string when manupilating header
+ # contents with re module. It would be best to return unicode in
+ # ch_oneline() but here is temporary solution.
subject = unicode(subject, cset)
# If the subject_prefix contains '%d', it is replaced with the
# mailing list sequential number. Sequential number format allows
@@ -316,7 +317,7 @@
else:
h = uheader(mlist, prefix, 'Subject', continuation_ws=ws)
h.append(recolon)
- # TK: Subject is concatnated and unicode string.
+ # TK: Subject is concatenated and unicode string.
subject = subject.encode(cset, 'replace')
h.append(subject, cset)
del msg['subject']
@@ -325,6 +326,7 @@
ss.append(subject, cset)
msgdata['stripped_subject'] = ss
+
def ch_oneline(s):
# Decode header string in one line and convert into single charset
Index: Decorate.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/Decorate.py,v
retrieving revision 2.25
retrieving revision 2.26
diff -u -d -r2.25 -r2.26
--- Decorate.py 24 Dec 2005 01:49:03 -0000 2.25
+++ Decorate.py 30 Dec 2005 18:56:46 -0000 2.26
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Decorate a message by sticking the header and footer around it."""
Index: MimeDel.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/MimeDel.py,v
retrieving revision 2.9
retrieving revision 2.10
diff -u -d -r2.9 -r2.10
--- MimeDel.py 28 Nov 2005 18:53:39 -0000 2.9
+++ MimeDel.py 30 Dec 2005 18:56:46 -0000 2.10
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""MIME-stripping filter for Mailman.
@@ -90,7 +91,6 @@
# headers. For now we'll move the subpart's payload into the outer part,
# and then copy over its Content-Type: and Content-Transfer-Encoding:
# headers (any others?).
- # TK: Make this configurable from Gui/ContentFilter.py.
if mlist.collapse_alternatives:
collapse_multipart_alternatives(msg)
if ctype == 'multipart/alternative':
Index: SMTPDirect.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/SMTPDirect.py,v
retrieving revision 2.34
retrieving revision 2.35
diff -u -d -r2.34 -r2.35
--- SMTPDirect.py 13 Nov 2005 20:41:09 -0000 2.34
+++ SMTPDirect.py 30 Dec 2005 18:56:46 -0000 2.35
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Local SMTP direct drop-off.
@@ -135,11 +136,11 @@
t0 = time.time()
# Open the initial connection
origrecips = msgdata['recips']
- # MAS: get the message sender now for logging. If we're using 'sender'
- # and not 'from', bulkdeliver changes it for bounce processing.
- # If we're VERPing, it doesn't matter because bulkdeliver is working
- # on a copy, but otherwise msg gets changed. If the list is anonymous,
- # the original sender is long gone, but Cleanse.py has logged it.
+ # MAS: get the message sender now for logging. If we're using 'sender'
+ # and not 'from', bulkdeliver changes it for bounce processing. If we're
+ # VERPing, it doesn't matter because bulkdeliver is working on a copy, but
+ # otherwise msg gets changed. If the list is anonymous, the original
+ # sender is long gone, but Cleanse.py has logged it.
origsender = msgdata.get('original_sender', msg.get_sender())
# `undelivered' is a copy of chunks that we pop from to do deliveries.
# This seems like a good tradeoff between robustness and resource
Index: Scrubber.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/Scrubber.py,v
retrieving revision 2.30
retrieving revision 2.31
diff -u -d -r2.30 -r2.31
--- Scrubber.py 24 Dec 2005 01:49:03 -0000 2.30
+++ Scrubber.py 30 Dec 2005 18:56:46 -0000 2.31
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Cleanse a message for archiving."""
@@ -162,9 +163,9 @@
def replace_payload_by_text(msg, text, charset):
- # TK: This is a common function in replacing the attachment and
- # the main message by a text (scrubbing). Plus a flag indicating
- # it has been scrubbed.
+ # TK: This is a common function in replacing the attachment and the main
+ # message by a text (scrubbing). Also, add a flag indicating it has been
+ # scrubbed.
del msg['content-type']
del msg['content-transfer-encoding']
msg.set_payload(text, charset)
@@ -218,7 +219,7 @@
raise DiscardMessage
replace_payload_by_text(part,
_('HTML attachment scrubbed and removed'),
- # Adding charset arg and removing content-tpe
+ # Adding charset arg and removing content-type
# sets content-type to text/plain
lcset)
elif sanitize == 2:
Index: SpamDetect.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/SpamDetect.py,v
retrieving revision 2.5
retrieving revision 2.6
diff -u -d -r2.5 -r2.6
--- SpamDetect.py 28 Aug 2005 05:31:27 -0000 2.5
+++ SpamDetect.py 30 Dec 2005 18:56:46 -0000 2.6
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2004 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Do more detailed spam detection.
@@ -67,7 +68,7 @@
def write(self, s):
self._outfp_a.write(s)
self._outfp_b.write(s)
-
+
# Class to capture the headers separate from the message body
class HeaderGenerator(Generator):
@@ -91,10 +92,9 @@
def process(mlist, msg, msgdata):
- # Don't check if the message has been approved OR it is generated
- # internally for administration because holding '-owner' notification
- # may cause infinite loop of checking. (Actually, it is stopped
- # elsewhere.)
+ # Don't check for spam if the message has been approved or it is generated
+ # internally for administration because holding '-owner' notification may
+ # cause infinite loop of checking. (Actually, it is stopped elsewhere.)
if msgdata.get('approved') or msg.get('x-list-administrivia'):
return
# First do site hard coded header spam checks
Index: ToArchive.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/ToArchive.py,v
retrieving revision 2.8
retrieving revision 2.9
diff -u -d -r2.8 -r2.9
--- ToArchive.py 24 Dec 2005 01:49:03 -0000 2.8
+++ ToArchive.py 30 Dec 2005 18:56:46 -0000 2.9
@@ -1,18 +1,19 @@
-# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Add the message to the archives."""
Index: ToDigest.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/ToDigest.py,v
retrieving revision 2.32
retrieving revision 2.33
diff -u -d -r2.32 -r2.33
--- ToDigest.py 24 Dec 2005 01:49:03 -0000 2.32
+++ ToDigest.py 30 Dec 2005 18:56:46 -0000 2.33
@@ -12,10 +12,10 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
-"""Add the message to the list's current digest and possibly send it.
-"""
+"""Add the message to the list's current digest and possibly send it."""
# Messages are accumulated to a Unix mailbox compatible file containing all
# the messages destined for the digest. This file must be parsable by the
@@ -90,19 +90,17 @@
# This is a bit of a kludge to get the mbox file moved to the digest
# queue directory.
try:
- # Let's close in try - except here because a error in send_digest
- # can stop regular delivery silently. Unsuccessful digest
- # delivery should be tried again by cron and the site
- # administrator will be notified of any error explicitly by the
- # cron error message.
+ # Enclose in try/except here because a error in send_digest() can
+ # silently stop regular delivery. Unsuccessful digest delivery
+ # should be tried again by cron and the site administrator will be
+ # notified of any error explicitly by the cron error message.
mboxfp.seek(0)
send_digests(mlist, mboxfp)
os.unlink(mboxfile)
except Exception, errmsg:
- # I know bare except is prohibited in mailman coding but we can't
- # forcast what new exception can occur here.
+ # Bare except is generally prohibited in Mailman, but we can't
+ # forecast what exceptions can occur here.
syslog('error', 'send_digests() failed: %s', errmsg)
- pass
mboxfp.close()
@@ -341,7 +339,7 @@
else:
# If decoded payload is empty, this may be multipart message.
# -- just stringfy it.
- payload = msg.get_payload(decode=True)\
+ payload = msg.get_payload(decode=True) \
or msg.as_string().split('\n\n',1)[1]
mcset = msg.get_content_charset('')
if mcset and mcset <> lcset and mcset <> lcset_out:
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org