diff options
author | Mark Sapiro <msapiro@value.net> | 2011-11-17 12:55:13 -0800 |
---|---|---|
committer | Mark Sapiro <msapiro@value.net> | 2011-11-17 12:55:13 -0800 |
commit | 05dafc005f8dc71aadd8602418f44434cf64a352 (patch) | |
tree | 38f328d548972e650d7297974f06a2ac9dd35cc4 /Mailman/Handlers/Tagger.py | |
parent | a5cf72fd54db8261f0398e449d633247efbe40a2 (diff) | |
download | mailman2-05dafc005f8dc71aadd8602418f44434cf64a352.tar.gz mailman2-05dafc005f8dc71aadd8602418f44434cf64a352.tar.xz mailman2-05dafc005f8dc71aadd8602418f44434cf64a352.zip |
Fixed a problem where topics regexps would not match RFC 2047 encoded
Keywords: and/or Subject: headers. Bug #891676.
Diffstat (limited to 'Mailman/Handlers/Tagger.py')
-rw-r--r-- | Mailman/Handlers/Tagger.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Mailman/Handlers/Tagger.py b/Mailman/Handlers/Tagger.py index 0d3ce497..38a8e465 100644 --- a/Mailman/Handlers/Tagger.py +++ b/Mailman/Handlers/Tagger.py @@ -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,9 @@ import email.Errors import email.Iterators import email.Parser +from email.Header import decode_header + +from Mailman import Utils from Mailman.Logging.Syslog import syslog CRNL = '\r\n' @@ -34,10 +37,16 @@ NLTAB = '\n\t' def process(mlist, msg, msgdata): if not mlist.topics_enabled: return + # Helper function. Return RFC 2047 decoded header as a string in the + # charset of the list's preferred language. + def _decode(h): + if not h: + return h + return Utils.oneline(h, Utils.GetCharSet(mlist.preferred_language)) # 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 +93,7 @@ def scanbody(msg, numlines=None): # 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) |