From 03cb2bdc170d1ced6e69f75e51198871f378f557 Mon Sep 17 00:00:00 2001 From: tkikuchi <> Date: Fri, 17 Feb 2006 02:42:35 +0000 Subject: ch_oneline(): Input string variable is overwritten. Also use list comprehension where appropriate. --- Mailman/Handlers/CookHeaders.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py index 309c8451..ea51abf1 100644 --- a/Mailman/Handlers/CookHeaders.py +++ b/Mailman/Handlers/CookHeaders.py @@ -327,20 +327,16 @@ def prefix_subject(mlist, msg, msgdata): -def ch_oneline(s): +def ch_oneline(headerstr): # Decode header string in one line and convert into single charset # copied and modified from ToDigest.py and Utils.py # return (string, cset) tuple as check for failure try: - d = decode_header(s) + d = decode_header(headerstr) # at this point, we should rstrip() every string because some # MUA deliberately add trailing spaces when composing return # message. - i = 0 - for (s,c) in d: - s = s.rstrip() - d[i] = (s,c) - i += 1 + d = [(s.rstrip(), c) for (s,c) in d] cset = 'us-ascii' for x in d: # search for no-None charset @@ -353,4 +349,4 @@ def ch_oneline(s): return oneline.encode(cset, 'replace'), cset except (LookupError, UnicodeError, ValueError, HeaderParseError): # possibly charset problem. return with undecoded string in one line. - return ''.join(s.splitlines()), 'us-ascii' + return ''.join(headerstr.splitlines()), 'us-ascii' -- cgit v1.2.3