aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Mailman/Handlers/MimeDel.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/Mailman/Handlers/MimeDel.py b/Mailman/Handlers/MimeDel.py
index 89b03644..b55bd5c4 100644
--- a/Mailman/Handlers/MimeDel.py
+++ b/Mailman/Handlers/MimeDel.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2009 by the Free Software Foundation, Inc.
+# Copyright (C) 2002-2011 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
@@ -96,6 +96,11 @@ def process(mlist, msg, msgdata):
if ctype == 'multipart/alternative':
firstalt = msg.get_payload(0)
reset_payload(msg, firstalt)
+ # Now that we've collapsed the MPA parts, go through the message
+ # and recast any multipart parts with only one sub-part as just
+ # the sub-part.
+ if msg.is_multipart():
+ recast_multipart(msg)
# If we removed some parts, make note of this
changedp = 0
if numparts <> len([subpart for subpart in msg.walk()]):
@@ -194,6 +199,21 @@ def collapse_multipart_alternatives(msg):
+def recast_multipart(msg):
+ # If we're left with a multipart message with only one sub-part, recast
+ # the message to just the sub-part.
+ if msg.is_multipart():
+ if len(msg.get_payload()) == 1:
+ reset_payload(msg, msg.get_payload(0))
+ # now that we've recast this part, check the subordinate parts
+ recast_multipart(msg)
+ else:
+ # This part's OK but check deeper.
+ for part in msg.get_payload():
+ recast_multipart(part)
+
+
+
def to_plaintext(msg):
changedp = 0
for subpart in typed_subpart_iterator(msg, 'text', 'html'):