--- f:/test-mailman-2.1/Mailman/Handlers/Tagger.py 2008-12-02 11:42:30.000000000 -0800 +++ f:/test-mailman/Mailman/Handlers/Tagger.py 2011-11-17 09:04:21.968750000 -0800 @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2011 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -23,6 +23,8 @@ import email.Iterators import email.Parser +from email.Header import decode_header + from Mailman.Logging.Syslog import syslog CRNL = '\r\n' @@ -34,10 +36,15 @@ def process(mlist, msg, msgdata): if not mlist.topics_enabled: return + # Helper function + def _decode(h): + if not h: + return h + return ''.join([x[0] for x in decode_header(h)]) # Extract the Subject:, Keywords:, and possibly body text matchlines = [] - matchlines.append(msg.get('subject', None)) - matchlines.append(msg.get('keywords', None)) + matchlines.append(_decode(msg.get('subject', None))) + matchlines.append(_decode(msg.get('keywords', None))) if mlist.topics_bodylines_limit == 0: # Don't scan any body lines pass @@ -84,7 +91,7 @@ # the first numlines of body text. lines = [] lineno = 0 - reader = list(email.Iterators.body_line_iterator(msg)) + reader = list(email.Iterators.body_line_iterator(msg, decode=True)) while numlines is None or lineno < numlines: try: line = reader.pop(0)