diff options
author | bwarsaw <> | 2003-12-18 14:57:29 +0000 |
---|---|---|
committer | bwarsaw <> | 2003-12-18 14:57:29 +0000 |
commit | 4449fa2eca5cc86990e1cde67460c9f9e39c49f5 (patch) | |
tree | 370d0803b5ecb94a787dead7bcfcea74b7de7a5c | |
parent | 9d78d653a0e8dd7d762b520bdd311fbbf483e2c5 (diff) | |
download | mailman2-4449fa2eca5cc86990e1cde67460c9f9e39c49f5.tar.gz mailman2-4449fa2eca5cc86990e1cde67460c9f9e39c49f5.tar.xz mailman2-4449fa2eca5cc86990e1cde67460c9f9e39c49f5.zip |
uheader(): Added default argument for maxlinelen.
process(): Reworked the way we calculate the List-Id header in the
face of i18n descriptions which may need to be quoted (if ASCII and
containing RFC 2822 special chars).
What we do now is RFC 2047 encode just the description part, if there
is one, then use formataddr() to combine that with the email
address-like list identification.
Diffstat (limited to '')
-rw-r--r-- | Mailman/Handlers/CookHeaders.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py index 6e8c0c6c..8e47d301 100644 --- a/Mailman/Handlers/CookHeaders.py +++ b/Mailman/Handlers/CookHeaders.py @@ -39,7 +39,7 @@ MAXLINELEN = 78 def _isunicode(s): return isinstance(s, UnicodeType) -def uheader(mlist, s, header_name=None, continuation_ws='\t'): +def uheader(mlist, s, header_name=None, continuation_ws='\t', maxlinelen=None): # 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,8 +54,7 @@ def uheader(mlist, s, header_name=None, continuation_ws='\t'): 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, - continuation_ws=continuation_ws) + return Header(s, charset, maxlinelen, header_name, continuation_ws) @@ -164,16 +163,18 @@ def process(mlist, msg, msgdata): # headers by default, pissing off their users. Too bad. Fix the MUAs. if msgdata.get('_nolist') or not mlist.include_rfc2369_headers: return - # Pre-calculate - listid = '<%s.%s>' % (mlist.internal_name(), mlist.host_name) + # This will act like an email address for purposes of formataddr() + listid = '%s.%s' % (mlist.internal_name(), mlist.host_name) if mlist.description: - # Make sure description is properly i18n'd - listid_h = uheader(mlist, u'"' + mlist.description + u'"', 'List-Id') - listid_h.append(listid, 'us-ascii') + # Don't wrap the header since here we just want to get it properly RFC + # 2047 encoded. + h = uheader(mlist, mlist.description, 'List-Id', maxlinelen=10000) + desc = str(h) else: - # For wrapping - listid_h = Header(listid, 'us-ascii', header_name='List-Id') - # We always add a List-ID: header. + desc = '' + listid_h = formataddr((desc, listid)) + # We always add a List-ID: header. Do an parse/format roundtrip to + # properly quote any funny characters in the description. del msg['list-id'] msg['List-Id'] = listid_h # For internally crafted messages, we |