aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman
diff options
context:
space:
mode:
authorMark Sapiro <msapiro@value.net>2011-01-13 17:00:40 -0800
committerMark Sapiro <msapiro@value.net>2011-01-13 17:00:40 -0800
commite568dea9f2c2fa0855f1742eeab7d0bd24e7a158 (patch)
tree455e443f036edb855e95ef98b465ac6c63cb6dd6 /Mailman
parent07e69cf16e80a1514f0e7e6f8110063eeb738c44 (diff)
downloadmailman2-e568dea9f2c2fa0855f1742eeab7d0bd24e7a158.tar.gz
mailman2-e568dea9f2c2fa0855f1742eeab7d0bd24e7a158.tar.xz
mailman2-e568dea9f2c2fa0855f1742eeab7d0bd24e7a158.zip
- Fixed a bug where content filtering could leave a multipart message or
part with just one sub-part. These should be recast to just the sub-part. Bug #701558.
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'):