diff options
author | David Planella <david.planella@gmail.com> | 2009-01-29 00:22:52 +0100 |
---|---|---|
committer | David Planella <david.planella@gmail.com> | 2009-01-29 00:22:52 +0100 |
commit | 518b3843c0117f24b1b277a724169fb616604e4d (patch) | |
tree | 01ab5cbe392ff3a8e851dae1be4eb3a8cf8ed439 /Mailman/Handlers | |
parent | 42fcf522d7818e9e1ee922d1a68824b0f6dcc83d (diff) | |
parent | c0da6af58657b1fe5730d3dea0e78bc17dac490a (diff) | |
download | mailman2-518b3843c0117f24b1b277a724169fb616604e4d.tar.gz mailman2-518b3843c0117f24b1b277a724169fb616604e4d.tar.xz mailman2-518b3843c0117f24b1b277a724169fb616604e4d.zip |
Merged from upstream
Diffstat (limited to 'Mailman/Handlers')
-rw-r--r-- | Mailman/Handlers/Decorate.py | 14 | ||||
-rw-r--r-- | Mailman/Handlers/Scrubber.py | 13 | ||||
-rw-r--r-- | Mailman/Handlers/Tagger.py | 9 |
3 files changed, 24 insertions, 12 deletions
diff --git a/Mailman/Handlers/Decorate.py b/Mailman/Handlers/Decorate.py index 81bf7d33..4a6fb8aa 100644 --- a/Mailman/Handlers/Decorate.py +++ b/Mailman/Handlers/Decorate.py @@ -98,8 +98,16 @@ def process(mlist, msg, msgdata): # TK: Try to keep the message plain by converting the header/ # footer/oldpayload into unicode and encode with mcset/lcset. # Try to decode qp/base64 also. - uheader = unicode(header, lcset, 'ignore') - ufooter = unicode(footer, lcset, 'ignore') + # It is possible header/footer is already unicode if it was + # interpolated with a unicode. + if isinstance(header, unicode): + uheader = header + else: + uheader = unicode(header, lcset, 'ignore') + if isinstance(footer, unicode): + ufooter = footer + else: + ufooter = unicode(footer, lcset, 'ignore') try: oldpayload = unicode(msg.get_payload(decode=True), mcset) frontsep = endsep = u'' @@ -130,7 +138,7 @@ def process(mlist, msg, msgdata): wrap = False except (LookupError, UnicodeError): pass - elif msg.get_type() == 'multipart/mixed': + elif msg.get_content_type() == 'multipart/mixed': # The next easiest thing to do is just prepend the header and append # the footer as additional subparts payload = msg.get_payload() diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py index 1d5aed92..64b46eaf 100644 --- a/Mailman/Handlers/Scrubber.py +++ b/Mailman/Handlers/Scrubber.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2007 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2009 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 @@ -21,7 +21,6 @@ from __future__ import nested_scopes import os import re -import sha import time import errno import binascii @@ -41,6 +40,7 @@ from Mailman import Message from Mailman.Errors import DiscardMessage from Mailman.i18n import _ from Mailman.Logging.Syslog import syslog +from Mailman.Utils import sha_new # Path characters for common platforms pre = re.compile(r'[/\\:]') @@ -158,7 +158,7 @@ def calculate_attachments_dir(mlist, msg, msgdata): if msgid is None: msgid = msg['Message-ID'] = Utils.unique_message_id(mlist) # We assume that the message id actually /is/ unique! - digest = sha.new(msgid).hexdigest() + digest = sha_new(msgid).hexdigest() return os.path.join('attachments', datedir, digest[:4] + digest[-4:]) @@ -167,6 +167,9 @@ def replace_payload_by_text(msg, text, charset): # message by a text (scrubbing). del msg['content-type'] del msg['content-transfer-encoding'] + if isinstance(charset, unicode): + # email 3.0.1 (python 2.4) doesn't like unicode + charset = charset.encode('us-ascii') msg.set_payload(text, charset) @@ -189,7 +192,7 @@ def process(mlist, msg, msgdata=None): # Now walk over all subparts of this message and scrub out various types format = delsp = None for part in msg.walk(): - ctype = part.get_type(part.get_default_type()) + ctype = part.get_content_type() # If the part is text/plain, we leave it alone if ctype == 'text/plain': # We need to choose a charset for the scrubbed message, so we'll @@ -300,7 +303,7 @@ URL: %(url)s # will transform the url into a hyperlink. elif part.get_payload() and not part.is_multipart(): payload = part.get_payload(decode=True) - ctype = part.get_type() + ctype = part.get_content_type() # XXX Under email 2.5, it is possible that payload will be None. # This can happen when you have a Content-Type: multipart/* with # only one part and that part has two blank lines between the diff --git a/Mailman/Handlers/Tagger.py b/Mailman/Handlers/Tagger.py index 65ead7f6..0d3ce497 100644 --- a/Mailman/Handlers/Tagger.py +++ b/Mailman/Handlers/Tagger.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2008 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 @@ -69,11 +69,12 @@ def scanbody(msg, numlines=None): # or if the outer type is multipart/alternative and there is a text/plain # part. Anything else, and the body is ignored for header-scan purposes. found = None - if msg.get_type('text/plain') == 'text/plain': + if msg.get_content_type() == 'text/plain': found = msg - elif msg.is_multipart() and msg.get_type() == 'multipart/alternative': + elif (msg.is_multipart() and + msg.get_content_type() == 'multipart/alternative'): for found in msg.get_payload(): - if found.get_type('text/plain') == 'text/plain': + if found.get_content_type() == 'text/plain': break else: found = None |