Hello mailman-developers ! I have for a long time been annoyed by the fact that Mailman adds more than one copy of the mailing-list-prefix to the Subject line in replies sent to a list. This can occur if the Subject line contains non-ASCII characters (this has been reported in the bug-database as bug #230400: "German Umlaute mess up subject-line and body"). It looks something like (if you can view this in your mailers :-)): Subject: Re: [Test] Re: [Test] räkmsörgås The reason seems to be that Mailman has the following "algorithm" to decide what to do: - add list-name-prefix (if it isn't already there) instead of the more correct: - MIME-decode the subject - add list-name-prefix (if it isn't already there) - MIME-reencode the subject If no MIME-decoding is done, Mailman can fail to detect the precense of a mailing-list-prefix, since the prefix can be "buried" in the MIME-encoded stuff. I have made a patch to "CookHeaders.py" that fixes this problem, and implements the second alternative above (see the attached patch). Could something like this be added to future versions of Mailman ?? (I don't know if I have made the change the right way (I'm not a Python programmer)). /Johan Holmberg
*** CookHeaders.py.orig Fri Feb 16 13:40:19 2001 --- CookHeaders.py Wed Apr 11 14:00:17 2001 *************** *** 20,28 **** --- 20,52 ---- import string import re import urlparse + import mimify + from Mailman import mm_cfg + #---------------------------------------------------------------------- + # This function MIME-decodes the subject before deciding if a + # prefix should be added. IF we change the subject we have to + # "reencode" it before sending it. + # + # This is a "hack" made by Johan Holmberg <[EMAIL PROTECTED]>. + # Seems to work, but I'm no Python programmer (prefers Perl/Ruby :-)) + # Use it at your own risk. + # + + def add_prefix(prefix,subject): + if not prefix: return subject + text = mimify.mime_decode_header(subject) + if re.search(re.escape(prefix), text, re.I): + return subject + else: + text = prefix + subject + text = mimify.mime_encode_header(text) + return text + + #---------------------------------------------------------------------- + def process(mlist, msg, msgdata): # Mark the message as dirty so that its text will be forced to disk next *************** *** 48,55 **** # we purposefully leave no space b/w prefix and subject! if not subject: msg['Subject'] = prefix + '(no subject)' ! elif prefix and not re.search(re.escape(prefix), subject, re.I): ! msg['Subject'] = prefix + subject # # get rid of duplicate headers del msg['sender'] --- 72,79 ---- # we purposefully leave no space b/w prefix and subject! if not subject: msg['Subject'] = prefix + '(no subject)' ! elif prefix: ! msg['Subject'] = add_prefix(prefix,subject) # # get rid of duplicate headers del msg['sender']