1 |
=== modified file 'Mailman/Handlers/SMTPDirect.py' |
2 |
--- Mailman/Handlers/SMTPDirect.py 2005-12-30 18:50:08 +0000 |
3 |
+++ Mailman/Handlers/SMTPDirect.py 2009-08-01 23:15:35 +0000 |
4 |
@@ -1,4 +1,4 @@ |
5 |
-# Copyright (C) 1998-2005 by the Free Software Foundation, Inc. |
6 |
+# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. |
7 |
# |
8 |
# This program is free software; you can redistribute it and/or |
9 |
# modify it under the terms of the GNU General Public License |
10 |
@@ -360,7 +360,9 @@ |
11 |
msg['Sender'] = envsender |
12 |
msg['Errors-To'] = envsender |
13 |
# Get the plain, flattened text of the message, sans unixfrom |
14 |
- msgtext = msg.as_string() |
15 |
+ # using our as_string() method to not mangle From_ and not fold |
16 |
+ # sub-part headers possibly breaking signatures. |
17 |
+ msgtext = msg.as_string(mangle_from_=False) |
18 |
refused = {} |
19 |
recips = msgdata['recips'] |
20 |
msgid = msg['message-id'] |
21 |
|
22 |
=== modified file 'Mailman/Handlers/Scrubber.py' |
23 |
--- Mailman/Handlers/Scrubber.py 2009-07-31 22:37:29 +0000 |
24 |
+++ Mailman/Handlers/Scrubber.py 2009-08-01 23:15:35 +0000 |
25 |
@@ -90,27 +90,6 @@ |
26 |
return all and all[0] |
27 |
|
28 |
|
29 |
- |
30 |
-# We're using a subclass of the standard Generator because we want to suppress |
31 |
-# headers in the subparts of multiparts. We use a hack -- the ctor argument |
32 |
-# skipheaders to accomplish this. It's set to true for the outer Message |
33 |
-# object, but false for all internal objects. We recognize that |
34 |
-# sub-Generators will get created passing only mangle_from_ and maxheaderlen |
35 |
-# to the ctors. |
36 |
-# |
37 |
-# This isn't perfect because we still get stuff like the multipart boundaries, |
38 |
-# but see below for how we corrupt that to our nefarious goals. |
39 |
-class ScrubberGenerator(Generator): |
40 |
- def __init__(self, outfp, mangle_from_=True, |
41 |
- maxheaderlen=78, skipheaders=True): |
42 |
- Generator.__init__(self, outfp, mangle_from_=False) |
43 |
- self.__skipheaders = skipheaders |
44 |
- |
45 |
- def _write_headers(self, msg): |
46 |
- if not self.__skipheaders: |
47 |
- Generator._write_headers(self, msg) |
48 |
- |
49 |
- |
50 |
def safe_strftime(fmt, t): |
51 |
try: |
52 |
return time.strftime(fmt, t) |
53 |
|
54 |
=== modified file 'Mailman/Mailbox.py' |
55 |
--- Mailman/Mailbox.py 2005-08-27 01:40:17 +0000 |
56 |
+++ Mailman/Mailbox.py 2009-08-01 23:15:35 +0000 |
57 |
@@ -1,4 +1,4 @@ |
58 |
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc. |
59 |
+# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. |
60 |
# |
61 |
# This program is free software; you can redistribute it and/or |
62 |
# modify it under the terms of the GNU General Public License |
63 |
@@ -22,10 +22,10 @@ |
64 |
|
65 |
import email |
66 |
from email.Parser import Parser |
67 |
-from email.Generator import Generator |
68 |
from email.Errors import MessageParseError |
69 |
|
70 |
from Mailman import mm_cfg |
71 |
+from Mailman.Message import Generator |
72 |
from Mailman.Message import Message |
73 |
|
74 |
try: |
75 |
|
76 |
=== modified file 'Mailman/Message.py' |
77 |
--- Mailman/Message.py 2007-06-29 21:24:32 +0000 |
78 |
+++ Mailman/Message.py 2009-08-01 23:15:35 +0000 |
79 |
@@ -1,4 +1,4 @@ |
80 |
-# Copyright (C) 1998-2007 by the Free Software Foundation, Inc. |
81 |
+# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. |
82 |
# |
83 |
# This program is free software; you can redistribute it and/or |
84 |
# modify it under the terms of the GNU General Public License |
85 |
@@ -17,12 +17,15 @@ |
86 |
|
87 |
"""Standard Mailman message object. |
88 |
|
89 |
-This is a subclass of mimeo.Message but provides a slightly extended interface |
90 |
+This is a subclass of email.Message but provides a slightly extended interface |
91 |
which is more convenient for use inside Mailman. |
92 |
""" |
93 |
|
94 |
import re |
95 |
+from cStringIO import StringIO |
96 |
+ |
97 |
import email |
98 |
+import email.Generator |
99 |
import email.Message |
100 |
import email.Utils |
101 |
from email.Charset import Charset |
102 |
@@ -40,6 +43,24 @@ |
103 |
|
104 |
|
105 |
|
106 |
+class Generator(email.Generator.Generator): |
107 |
+ """Generates output from a Message object tree, keeping signatures. |
108 |
+ |
109 |
+ Headers will by default _not_ be folded in attachments. |
110 |
+ """ |
111 |
+ def __init__(self, outfp, mangle_from_=True, |
112 |
+ maxheaderlen=78, children_maxheaderlen=0): |
113 |
+ email.Generator.Generator.__init__(self, outfp, |
114 |
+ mangle_from_=mangle_from_, maxheaderlen=maxheaderlen) |
115 |
+ self.__children_maxheaderlen = children_maxheaderlen |
116 |
+ |
117 |
+ def clone(self, fp): |
118 |
+ """Clone this generator with maxheaderlen set for children""" |
119 |
+ return self.__class__(fp, self._mangle_from_, |
120 |
+ self.__children_maxheaderlen, self.__children_maxheaderlen) |
121 |
+ |
122 |
+ |
123 |
+ |
124 |
class Message(email.Message.Message): |
125 |
def __init__(self): |
126 |
# We need a version number so that we can optimize __setstate__() |
127 |
@@ -208,6 +229,20 @@ |
128 |
return failobj |
129 |
|
130 |
|
131 |
+ def as_string(self, unixfrom=False, mangle_from_=True): |
132 |
+ """Return entire formatted message as a string using |
133 |
+ Mailman.Message.Generator. |
134 |
+ |
135 |
+ Operates like email.Message.Message.as_string, only |
136 |
+ using Mailman's Message.Generator class. Only the top headers will |
137 |
+ get folded. |
138 |
+ """ |
139 |
+ fp = StringIO() |
140 |
+ g = Generator(fp, mangle_from_=mangle_from_) |
141 |
+ g.flatten(self, unixfrom=unixfrom) |
142 |
+ return fp.getvalue() |
143 |
+ |
144 |
+ |
145 |
|
146 |
class UserNotification(Message): |
147 |
"""Class for internally crafted messages.""" |
148 |
|
149 |
|