Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.1:Update
mailman
mailman-2.1.4-avoid-headerfolding-python21.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File mailman-2.1.4-avoid-headerfolding-python21.diff of Package mailman
Attempt to make Mailman leave signatures intact. Submessage parts will not get headers folded if the new Mailman.Generator.Generator class is used. Hopefully fixes, Mailman SF Bug: [ 815297 ] Breaking signatures in message/rfc822 attachement! Removed unused class ScrubberGenerator from Handlers/Scrupper.py along the way. It irritated me while searching for the solution. 20040412 Bernhard Reiter <bernhard@gnu.org> Added True/False fallbacks for Python 2.1 20040414 Thomas Arendsen Hein <thomas@intevation.de> diff -urN mailman-2.1.4/Mailman/Generator.py mailman-2.1.4-1/Mailman/Generator.py --- mailman-2.1.4/Mailman/Generator.py Thu Jan 1 01:00:00 1970 +++ mailman-2.1.4-1/Mailman/Generator.py Wed Apr 14 12:13:17 2004 @@ -0,0 +1,64 @@ +# Copyright (C) 1998-2003 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 +# 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> + +"""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. + + Using the a trick from Mailman/Handlers/Scrubber.py (revs 2.0-2.15): + + Most other Generator will be created not setting the foldheader flag, + as we do not overwrite clone(). The original clone() does not + set foldheaders. + + So you need to set foldheaders if you want the toplevel to fold headers. + """ + def __init__(self, outfp, mangle_from_=True, + maxheaderlen=78, foldheaders=False): + email.Generator.Generator.__init__(self, outfp, mangle_from_=False) + self.__foldheaders = foldheaders + + def _write_headers(self, msg): + if self.__foldheaders: + email.Generator.Generator._write_headers(self, msg) + else: + # the following is + # unrolled from email.Generator.Generator._write_headers() + for h, v in msg.items(): + print >> self._fp, '%s:' % h, + print >> self._fp, v + print >> self._fp + diff -urN mailman-2.1.4/Mailman/Mailbox.py mailman-2.1.4-1/Mailman/Mailbox.py --- mailman-2.1.4/Mailman/Mailbox.py Sat Apr 19 06:57:14 2003 +++ mailman-2.1.4-1/Mailman/Mailbox.py Wed Apr 14 12:12:23 2004 @@ -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, foldheaders=True) g.flatten(msg, unixfrom=True) # Add one more trailing newline for separation with the next message # to be appended to the mbox. diff -urN mailman-2.1.4/Mailman/Message.py mailman-2.1.4-1/Mailman/Message.py --- mailman-2.1.4/Mailman/Message.py Mon Mar 31 23:49:38 2003 +++ mailman-2.1.4-1/Mailman/Message.py Wed Apr 14 12:13:17 2004 @@ -21,6 +21,8 @@ """ import re +from cStringIO import StringIO + import email import email.Message import email.Utils @@ -31,6 +33,13 @@ from Mailman import mm_cfg from Mailman import Utils +from Mailman.Generator import Generator + +try: + True, False +except NameError: + True = 1 + False = 0 COMMASPACE = ', ' @@ -187,6 +196,18 @@ address = address.lower() 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, foldheaders=True) + g.flatten(self, unixfrom=unixfrom) + return fp.getvalue() +
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor