aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Mailman/Handlers/SMTPDirect.py6
-rw-r--r--Mailman/Handlers/Scrubber.py21
-rw-r--r--Mailman/Mailbox.py4
-rw-r--r--Mailman/Message.py39
-rw-r--r--NEWS5
5 files changed, 48 insertions, 27 deletions
diff --git a/Mailman/Handlers/SMTPDirect.py b/Mailman/Handlers/SMTPDirect.py
index 72b587e9..8e3c7d73 100644
--- a/Mailman/Handlers/SMTPDirect.py
+++ b/Mailman/Handlers/SMTPDirect.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-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
@@ -360,7 +360,9 @@ def bulkdeliver(mlist, msg, msgdata, envsender, failures, conn):
msg['Sender'] = envsender
msg['Errors-To'] = envsender
# Get the plain, flattened text of the message, sans unixfrom
- msgtext = msg.as_string()
+ # using our as_string() method to not mangle From_ and not fold
+ # sub-part headers possibly breaking signatures.
+ msgtext = msg.as_string(mangle_from_=False)
refused = {}
recips = msgdata['recips']
msgid = msg['message-id']
diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py
index a990d721..b39f36d2 100644
--- a/Mailman/Handlers/Scrubber.py
+++ b/Mailman/Handlers/Scrubber.py
@@ -90,27 +90,6 @@ def guess_extension(ctype, ext):
return all and all[0]
-
-# We're using a subclass of the standard Generator because we want to suppress
-# headers in the subparts of multiparts. We use a hack -- the ctor argument
-# skipheaders to accomplish this. It's set to true for the outer Message
-# object, but false for all internal objects. We recognize that
-# sub-Generators will get created passing only mangle_from_ and maxheaderlen
-# to the ctors.
-#
-# This isn't perfect because we still get stuff like the multipart boundaries,
-# but see below for how we corrupt that to our nefarious goals.
-class ScrubberGenerator(Generator):
- def __init__(self, outfp, mangle_from_=True,
- maxheaderlen=78, skipheaders=True):
- Generator.__init__(self, outfp, mangle_from_=False)
- self.__skipheaders = skipheaders
-
- def _write_headers(self, msg):
- if not self.__skipheaders:
- Generator._write_headers(self, msg)
-
-
def safe_strftime(fmt, t):
try:
return time.strftime(fmt, t)
diff --git a/Mailman/Mailbox.py b/Mailman/Mailbox.py
index 03a13840..1b281a4c 100644
--- a/Mailman/Mailbox.py
+++ b/Mailman/Mailbox.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-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
@@ -22,10 +22,10 @@ import mailbox
import email
from email.Parser import Parser
-from email.Generator import Generator
from email.Errors import MessageParseError
from Mailman import mm_cfg
+from Mailman.Message import Generator
from Mailman.Message import Message
try:
diff --git a/Mailman/Message.py b/Mailman/Message.py
index 3c2ef605..84e4aa26 100644
--- a/Mailman/Message.py
+++ b/Mailman/Message.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-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
@@ -17,12 +17,15 @@
"""Standard Mailman message object.
-This is a subclass of mimeo.Message but provides a slightly extended interface
+This is a subclass of email.Message but provides a slightly extended interface
which is more convenient for use inside Mailman.
"""
import re
+from cStringIO import StringIO
+
import email
+import email.Generator
import email.Message
import email.Utils
from email.Charset import Charset
@@ -40,6 +43,24 @@ VERSION = tuple([int(s) for s in mo.group().split('.')])
+class Generator(email.Generator.Generator):
+ """Generates output from a Message object tree, keeping signatures.
+
+ Headers will by default _not_ be folded in attachments.
+ """
+ def __init__(self, outfp, mangle_from_=True,
+ maxheaderlen=78, children_maxheaderlen=0):
+ email.Generator.Generator.__init__(self, outfp,
+ mangle_from_=mangle_from_, maxheaderlen=maxheaderlen)
+ self.__children_maxheaderlen = children_maxheaderlen
+
+ def clone(self, fp):
+ """Clone this generator with maxheaderlen set for children"""
+ return self.__class__(fp, self._mangle_from_,
+ self.__children_maxheaderlen, self.__children_maxheaderlen)
+
+
+
class Message(email.Message.Message):
def __init__(self):
# We need a version number so that we can optimize __setstate__()
@@ -208,6 +229,20 @@ class Message(email.Message.Message):
return failobj
+ def as_string(self, unixfrom=False, mangle_from_=True):
+ """Return entire formatted message as a string using
+ Mailman.Message.Generator.
+
+ Operates like email.Message.Message.as_string, only
+ using Mailman's Message.Generator class. Only the top headers will
+ get folded.
+ """
+ fp = StringIO()
+ g = Generator(fp, mangle_from_=mangle_from_)
+ g.flatten(self, unixfrom=unixfrom)
+ return fp.getvalue()
+
+
class UserNotification(Message):
"""Class for internally crafted messages."""
diff --git a/NEWS b/NEWS
index 47bc5f73..e73c3ff7 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,11 @@ Here is a history of user visible changes to Mailman.
Bug Fixes and other patches
+ - Mailman no longer folds long sub-part headers in multipart messages.
+ In addition, Mailman no longer escapes From_ lines in the body of
+ messages sent to regular list members, although MTA's may do it anyway.
+ This is to avoid breaking signatures per Bug #265967.
+
- XSS protection in the web interface went too far in escaping HTML
entities. Fixed.