------------------------------------------------------------ revno: 981 committer: Mark Sapiro <[EMAIL PROTECTED]> branch nick: 2.1 timestamp: Fri 2007-06-22 10:49:27 -0700 message: Scrubber.py - Cleaned up a few loose ends and incomplete things left after the previous commit. - Normalized a couple more 'URL:'. - Improved handling of None payloads. - Cleaned up a few charset coercions. OutgoingRunner.py - Made probe bounce processing and queuing of bounces conditional on having some permanent failure(s). modified: Mailman/Handlers/Scrubber.py Mailman/Queue/OutgoingRunner.py
=== modified file 'Mailman/Handlers/Scrubber.py' --- a/Mailman/Handlers/Scrubber.py 2007-06-15 22:22:33 +0000 +++ b/Mailman/Handlers/Scrubber.py 2007-06-22 17:49:27 +0000 @@ -223,7 +223,7 @@ replace_payload_by_text(part, _("""\ An embedded and charset-unspecified text was scrubbed... Name: %(filename)s -Url: %(url)s +URL: %(url)s """), lcset) elif ctype == 'text/html' and isinstance(sanitize, IntType): if sanitize == 0: @@ -293,7 +293,7 @@ Subject: %(subject)s Date: %(date)s Size: %(size)s -Url: %(url)s +URL: %(url)s """), lcset) # If the message isn't a multipart, then we'll strip it out as an # attachment that would have to be separately downloaded. Pipermail @@ -316,6 +316,7 @@ finally: os.umask(omask) desc = part.get('content-description', _('not available')) + desc = Utils.oneline(desc, lcset) filename = part.get_filename(_('not available')) filename = Utils.oneline(filename, lcset) replace_payload_by_text(part, _("""\ @@ -324,7 +325,7 @@ Type: %(ctype)s Size: %(size)d bytes Desc: %(desc)s -Url : %(url)s +URL: %(url)s """), lcset) outer = False # We still have to sanitize multipart messages to flat text because @@ -356,14 +357,14 @@ text.append(_('Skipped content of type %(partctype)s\n')) continue try: - t = part.get_payload(decode=True) + t = part.get_payload(decode=True) or '' # MAS: TypeError exception can occur if payload is None. This # was observed with a message that contained an attached # message/delivery-status part. Because of the special parsing # of this type, this resulted in a text/plain sub-part with a # null body. See bug 1430236. except (binascii.Error, TypeError): - t = part.get_payload() + t = part.get_payload() or '' # TK: get_content_charset() returns 'iso-2022-jp' for internally # crafted (scrubbed) 'euc-jp' text part. So, first try # get_charset(), then get_content_charset() for the parts @@ -373,21 +374,20 @@ partcharset = str(partcharset) else: partcharset = part.get_content_charset() - # If the part is Content-Type: message/delivery-status, payload is - # None so test here. - if t and partcharset and partcharset <> charset: + if partcharset and partcharset <> charset: try: t = unicode(t, partcharset, 'replace') - except (UnicodeError, LookupError, ValueError, AssertionError): - # Replace funny characters. We use errors='replace' for - # both calls since the first replace will leave U+FFFD, - # which isn't ASCII encodeable. - u = unicode(t, 'ascii', 'replace') - t = u.encode('ascii', 'replace') + except (UnicodeError, LookupError, ValueError, + AssertionError): + # We can get here if partcharset is bogus in come way. + # Replace funny characters. We use errors='replace' + t = unicode(t, 'ascii', 'replace') try: # Should use HTML-Escape, or try generalizing to UTF-8 t = t.encode(charset, 'replace') - except (UnicodeError, LookupError, ValueError, AssertionError): + except (UnicodeError, LookupError, ValueError, + AssertionError): + # if the message charset is bogus, use the list's. t = t.encode(lcset, 'replace') # Separation is useful if isinstance(t, StringType): @@ -401,7 +401,8 @@ try: s = unicode(sep, lcset, 'replace') sep = s.encode(charset, 'replace') - except (UnicodeError, LookupError, ValueError): + except (UnicodeError, LookupError, ValueError, + AssertionError): pass replace_payload_by_text(msg, sep.join(text), charset) if format: @@ -479,7 +480,8 @@ # which one should we go with? For now, let's go with the one we # guessed so attachments can't lie about their type. Also, if the # filename /has/ no extension, then tack on the one we guessed. - filebase, ignore = os.path.splitext(filename) + # The extension was removed from the name above. + filebase = filename # Now we're looking for a unique name for this file on the file # system. If msgdir/filebase.ext isn't unique, we'll add a counter # after filebase, e.g. msgdir/filebase-cnt.ext === modified file 'Mailman/Queue/OutgoingRunner.py' --- a/Mailman/Queue/OutgoingRunner.py 2005-08-27 01:40:17 +0000 +++ b/Mailman/Queue/OutgoingRunner.py 2007-06-22 17:49:27 +0000 @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2004 by the Free Software Foundation, Inc. +# Copyright (C) 2000-2007 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. """Outgoing queue runner.""" @@ -91,7 +92,7 @@ return True except Errors.SomeRecipientsFailed, e: # Handle local rejects of probe messages differently. - if msgdata.get('probe_token'): + if msgdata.get('probe_token') and e.permfailures: self._probe_bounce(mlist, msgdata['probe_token']) else: # Delivery failed at SMTP time for some or all of the @@ -103,7 +104,9 @@ # this is what's sent to the user in the probe message. Maybe # we should craft a bounce-like message containing information # about the permanent SMTP failure? - self._queue_bounces(mlist.internal_name(), e.permfailures, msg) + if e.permfailures: + self._queue_bounces(mlist.internal_name(), e.permfailures, + msg) # Move temporary failures to the qfiles/retry queue which will # occasionally move them back here for another shot at # delivery. -- (no title) https://code.launchpad.net/~mailman-coders/mailman/2.1 You are receiving this branch notification because you are subscribed to it. To unsubscribe from this branch go to https://code.launchpad.net/~mailman-coders/mailman/2.1/+subscription/mailman-checkins. _______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org