Revision: 8233
http://svn.sourceforge.net/mailman/?rev=8233&view=rev
Author: msapiro
Date: 2007-06-09 12:31:51 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Improved processing of an Approve(d): body line by decoding the body payload
before looking for/deleting the Approve(d): line.
Modified Paths:
--------------
trunk/mailman/Mailman/Handlers/Approve.py
Modified: trunk/mailman/Mailman/Handlers/Approve.py
===================================================================
--- trunk/mailman/Mailman/Handlers/Approve.py 2007-06-09 19:30:36 UTC (rev
8232)
+++ trunk/mailman/Mailman/Handlers/Approve.py 2007-06-09 19:31:51 UTC (rev
8233)
@@ -58,7 +58,7 @@
# 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 @@
# 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 @@
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 @@
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)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org