diff options
author | bwarsaw <> | 2003-02-08 07:14:13 +0000 |
---|---|---|
committer | bwarsaw <> | 2003-02-08 07:14:13 +0000 |
commit | 925200da11d52ae4d7fc664bff898f8050bef687 (patch) | |
tree | 389bbd6c076718221b427d6d6e4fa199a1729ec0 /Mailman/Handlers/CookHeaders.py | |
parent | dea51d7d5a5c5d8ea6900a838a12e230b7a000b6 (diff) | |
download | mailman2-925200da11d52ae4d7fc664bff898f8050bef687.tar.gz mailman2-925200da11d52ae4d7fc664bff898f8050bef687.tar.xz mailman2-925200da11d52ae4d7fc664bff898f8050bef687.zip |
Backporting from the trunk.
Diffstat (limited to 'Mailman/Handlers/CookHeaders.py')
-rw-r--r-- | Mailman/Handlers/CookHeaders.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py index 40eddd66..c4ad06ab 100644 --- a/Mailman/Handlers/CookHeaders.py +++ b/Mailman/Handlers/CookHeaders.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2003 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 @@ -39,7 +39,7 @@ MAXLINELEN = 78 def _isunicode(s): return isinstance(s, UnicodeType) -def uheader(mlist, s, header_name=None): +def uheader(mlist, s, header_name=None, continuation_ws='\t'): # Get the charset to encode the string in. If this is us-ascii, we'll use # iso-8859-1 instead, just to get a little extra coverage, and because the # Header class tries us-ascii first anyway. @@ -54,7 +54,8 @@ def uheader(mlist, s, header_name=None): codec = charset.input_codec or 'ascii' s = unicode(s, codec, 'replace') # We purposefully leave no space b/w prefix and subject! - return Header(s, charset, header_name=header_name) + return Header(s, charset, header_name=header_name, + continuation_ws=continuation_ws) @@ -218,7 +219,15 @@ def prefix_subject(mlist, msg, msgdata): # tracked (e.g. internally crafted, delivered to a single user such as the # list admin). prefix = mlist.subject_prefix - subject = msg['subject'] + subject = msg.get('subject', '') + # Try to figure out what the continuation_ws is for the header + if isinstance(subject, Header): + lines = str(subject).splitlines() + else: + lines = subject.splitlines() + ws = '\t' + if len(lines) > 1 and lines[1] and lines[1][0] in ' \t': + ws = lines[1][0] msgdata['origsubj'] = subject # The header may be multilingual; decode it from base64/quopri and search # each chunk for the prefix. BAW: Note that if the prefix contains spaces @@ -235,7 +244,7 @@ def prefix_subject(mlist, msg, msgdata): if not subject: subject = _('(no subject)') # Get the header as a Header instance, with proper unicode conversion - h = uheader(mlist, prefix, 'Subject') + h = uheader(mlist, prefix, 'Subject', continuation_ws=ws) for s, c in headerbits: # Once again, convert the string to unicode. if c is None: |