Репозитории ALT
S: | 2.1.39-alt1 |
5.1: | 2.1.12-alt2 |
4.1: | 2.1.10-alt0.3.1.M41.1 |
4.0: | 2.1.9-alt6.M40.1 |
3.0: | 2.1.6-alt1 |
Группа :: Система/Серверы
Пакет: mailman
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: mailman-2.1.9-deb-77_header_folding_in_attachments.patch
Скачать
Скачать
Patch: 77_header_folding_in_attachments.patch
Author: Lionel Elie Mamane <lionel@mamane.lu>
Don't fold headers into message/rfc822 attachments.
This avoids breaking signatures.
Index: Mailman/Generator.py
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ Mailman/Generator.py 2006-08-15 15:14:57.000000000 +0800
@@ -0,0 +1,55 @@
+# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# 2005 Lionel Elie Mamane <lionel@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@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)
+
Index: Mailman/Mailbox.py
===================================================================
--- Mailman/Mailbox.py.orig 2006-08-15 15:12:10.000000000 +0800
+++ Mailman/Mailbox.py 2006-08-15 15:14:57.000000000 +0800
@@ -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.
Index: Mailman/Message.py
===================================================================
--- Mailman/Message.py.orig 2006-08-15 15:12:10.000000000 +0800
+++ Mailman/Message.py 2006-08-15 15:14:57.000000000 +0800
@@ -22,6 +22,8 @@
"""
import re
+from cStringIO import StringIO
+
import email
import email.Message
import email.Utils
@@ -32,6 +34,7 @@
from Mailman import mm_cfg
from Mailman import Utils
+from Mailman.Generator import Generator
COMMASPACE = ', '
@@ -199,6 +202,16 @@
except (UnicodeError, LookupError, ValueError):
return failobj
+ 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):