summaryrefslogtreecommitdiff
path: root/Mailman/Handlers/Approve.py
diff options
context:
space:
mode:
authormsapiro2007-06-09 19:31:51 +0000
committermsapiro2007-06-09 19:31:51 +0000
commit6bf540daa7291dac451290a3b5944413a827a5e1 (patch)
tree6816d943549501530bbc15001fee172e450bfb8d /Mailman/Handlers/Approve.py
parente5c04e2a93a58d799dd3940a7935853eb1f2e3e4 (diff)
downloadmailman-6bf540daa7291dac451290a3b5944413a827a5e1.tar.gz
mailman-6bf540daa7291dac451290a3b5944413a827a5e1.tar.zst
mailman-6bf540daa7291dac451290a3b5944413a827a5e1.zip
Diffstat (limited to 'Mailman/Handlers/Approve.py')
-rw-r--r--Mailman/Handlers/Approve.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/Mailman/Handlers/Approve.py b/Mailman/Handlers/Approve.py
index dc139d52b..1ff58abf0 100644
--- a/Mailman/Handlers/Approve.py
+++ b/Mailman/Handlers/Approve.py
@@ -58,7 +58,7 @@ def process(mlist, msg, msgdata):
# XXX I'm not entirely sure why, but it is possible for the payload of
# the part to be None, and you can't splitlines() on None.
if part is not None and part.get_payload() is not None:
- lines = part.get_payload().splitlines()
+ lines = part.get_payload(decode=True).splitlines()
line = ''
for lineno, line in zip(range(len(lines)), lines):
if line.strip():
@@ -72,7 +72,7 @@ def process(mlist, msg, msgdata):
# Now strip the first line from the payload so the
# password doesn't leak.
del lines[lineno]
- part.set_payload(NL.join(lines))
+ reset_payload(part, NL.join(lines))
stripped = True
if stripped:
# MAS: Bug 1181161 - Now try all the text parts in case it's
@@ -94,10 +94,9 @@ def process(mlist, msg, msgdata):
pattern = name + ':(\s| )*' + re.escape(passwd)
for part in typed_subpart_iterator(msg, 'text'):
if part is not None and part.get_payload() is not None:
- # Should we decode the payload?
- lines = part.get_payload()
+ lines = part.get_payload(decode=True)
if re.search(pattern, lines):
- part.set_payload(re.sub(pattern, '', lines))
+ reset_payload(part, re.sub(pattern, '', lines))
if passwd is not missing and mlist.Authenticate((config.AuthListModerator,
config.AuthListAdmin),
passwd):
@@ -110,3 +109,20 @@ def process(mlist, msg, msgdata):
beentheres = [s.strip().lower() for s in msg.get_all('x-beenthere', [])]
if mlist.GetListEmail().lower() in beentheres:
raise Errors.LoopError
+
+def reset_payload(part, payload):
+ # Set decoded payload maintaining content-type, format and delsp.
+ # TK: Message with 'charset=' cause trouble. So, instead of
+ # part.get_content_charset('us-ascii') ...
+ cset = part.get_content_charset() or 'us-ascii'
+ ctype = part.get_content_type()
+ format = part.get_param('format')
+ delsp = part.get_param('delsp')
+ del part['content-transfer-encoding']
+ del part['content-type']
+ part.set_payload(payload, cset)
+ part.set_type(ctype)
+ if format:
+ part.set_param('Format', format)
+ if delsp:
+ part.set_param('DelSp', delsp)