Bug#244673: [Pkg-mailman-hackers] Bug#244673: Your Mailman Debian bug
Lionel Elie Mamane
lionel at mamane.lu
Sun Dec 25 14:11:15 UTC 2005
On Sun, Dec 25, 2005 at 02:39:58PM +0100, Lionel Elie Mamane wrote:
> Here's the patch as it will go in the next Debian upload.
Really, this time.
--
Lionel
-------------- next part --------------
#! /bin/sh /usr/share/dpatch/dpatch-run
## 77_header_folding_in_attachments.dpatch by Lionel Elie Mamane <lionel at mamane.lu>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Don't fold headers into message/rfc822 attachments
## DP: This avoids breaking signatures
@DPATCH@
diff -urNad mailman-2.1.6~/Mailman/Generator.py mailman-2.1.6/Mailman/Generator.py
--- mailman-2.1.6~/Mailman/Generator.py 1970-01-01 01:00:00.000000000 +0100
+++ mailman-2.1.6/Mailman/Generator.py 2005-12-25 14:37:46.374075579 +0100
@@ -0,0 +1,55 @@
+# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# 2005 Lionel Elie Mamane <lionel at mamane.lu>
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Author: Bernhard Reiter <bernhard at gnu.org>
+# Changed by Lionel Elie Mamane December 2005 from version on
+# http://ftp.intevation.de/users/bernhard/mailman/mailman-2.1.4-avoid-headerfolding-python21.diff
+# to use clone/children_maxheaderlen trick instead of _write_headers/mangle_from_
+
+"""Standard Mailman generator object.
+
+A subclass of email.Generator which only folds long headers
+in the top object level.
+This is needed because Mailman should leave the reveiced message parts alone.
+Otherwise is might change subparts over which a signature was calculated,
+breaking it while doing so.
+"""
+
+import email
+import email.Generator
+
+try:
+ True, False
+except NameError:
+ True = 1
+ False = 0
+
+
+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_=False,
+ 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)
+
diff -urNad mailman-2.1.6~/Mailman/Mailbox.py mailman-2.1.6/Mailman/Mailbox.py
--- mailman-2.1.6~/Mailman/Mailbox.py 2003-04-19 06:57:14.000000000 +0200
+++ mailman-2.1.6/Mailman/Mailbox.py 2005-12-25 14:31:54.590515028 +0100
@@ -22,10 +22,10 @@
import email
from email.Parser import Parser
-from email.Generator import Generator
from email.Errors import MessageParseError
from Mailman import mm_cfg
+from Mailman.Generator import Generator
from Mailman.Message import Message
try:
@@ -65,7 +65,7 @@
# Seek to the last char of the mailbox
self.fp.seek(1, 2)
# Create a Generator instance to write the message to the file
- g = Generator(self.fp)
+ g = Generator(self.fp, mangle_from_=True)
g.flatten(msg, unixfrom=True)
# Add one more trailing newline for separation with the next message
# to be appended to the mbox.
diff -urNad mailman-2.1.6~/Mailman/Message.py mailman-2.1.6/Mailman/Message.py
--- mailman-2.1.6~/Mailman/Message.py 2005-04-29 14:04:48.000000000 +0200
+++ mailman-2.1.6/Mailman/Message.py 2005-12-25 14:31:54.590515028 +0100
@@ -21,6 +21,8 @@
"""
import re
+from cStringIO import StringIO
+
import email
import email.Message
import email.Utils
@@ -31,6 +33,7 @@
from Mailman import mm_cfg
from Mailman import Utils
+from Mailman.Generator import Generator
COMMASPACE = ', '
@@ -188,6 +191,16 @@
authors.append(address)
return authors
+ def as_string(self, unixfrom=False):
+ """Return entire formatted message as a string using Mailman.Generator.
+
+ Operates like email.Message.Message.as_string, only
+ using Mailman's Generator class. Only the top headers will get folded.
+ """
+ fp = StringIO()
+ g = Generator(fp)
+ g.flatten(self, unixfrom=unixfrom)
+ return fp.getvalue()
class UserNotification(Message):
More information about the Pkg-mailman-hackers
mailing list