From 27d6e3959e6c4563dbbd4812230d251237ba9fd9 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Wed, 2 Oct 2002 13:55:22 +0000 Subject: is_administrivia(): Change slightly the way the administrivia search text is calculated. Because msg['subject'] could be a Header instance, we need to str-ify it before appending it to the body lines. uncanonstr(): Coerce the return value to a byte string when html ref substitution is done. Note that this code probably needs to be converted to a type test of s (unicode vs. str). --- Mailman/Utils.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Mailman/Utils.py b/Mailman/Utils.py index 3443393fa..e5be24c0c 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -507,8 +507,12 @@ def is_administrivia(msg): if ADMINDATA.has_key(bodytext.strip().lower()): return 1 # Look at the first N lines and see if there is any administrivia on the - # line. BAW: N is currently hardcoded to 5. - for line in lines[:5] + [msg.get('subject', '')]: + # line. BAW: N is currently hardcoded to 5. str-ify the Subject: header + # because it may be an email.Header.Header instance rather than a string. + bodylines = lines[:5] + subject = str(msg.get('subject', '')) + bodylines.append(subject) + for line in bodylines: if not line.strip(): continue words = [word.lower() for word in line.split()] @@ -751,6 +755,7 @@ def uncanonstr(s, lang=None): charset = 'us-ascii' else: charset = GetCharSet(lang) + # BAW should change this to a type types of s try: return s.encode(charset, 'strict') except UnicodeError: @@ -761,4 +766,5 @@ def uncanonstr(s, lang=None): a.append('&#%3d;' % o) else: a.append(c) - return EMPTYSTRING.join(a) + # Join characters together and coerce to byte string + return str(EMPTYSTRING.join(a)) -- cgit v1.3.1