Barry Warsaw pushed to branch master at mailman / Mailman
Commits: 57eeb0b2 by Mark Sapiro at 2017-01-09T10:20:52-08:00 Allow email.header.Header() to determine appropriate encoding. - - - - - 1ead6109 by Barry Warsaw at 2017-01-10T02:14:25+00:00 Merge branch 'mm_215' into 'master' Allow email.header.Header() to determine appropriate encoding. Closes #215 See merge request !234 - - - - - 2 changed files: - src/mailman/handlers/cook_headers.py - src/mailman/handlers/tests/test_cook_headers.py Changes: ===================================== src/mailman/handlers/cook_headers.py ===================================== --- a/src/mailman/handlers/cook_headers.py +++ b/src/mailman/handlers/cook_headers.py @@ -17,7 +17,6 @@ """Cook a message's headers.""" -import re import logging from email.header import Header @@ -34,7 +33,6 @@ log = logging.getLogger('mailman.error') COMMASPACE = ', ' MAXLINELEN = 78 -NONASCII = re.compile('[^\s!-~]') @public @@ -49,13 +47,6 @@ def uheader(mlist, s, header_name=None, continuation_ws='\t', maxlinelen=None): If the header contains a newline, truncate it (see GL#273). """ charset = mlist.preferred_language.charset - if NONASCII.search(s): - # use list charset but ... - if charset == 'us-ascii': - charset = 'iso-8859-1' - else: - # there is no non-ascii so ... - charset = 'us-ascii' if '\n' in s: s = '{} [...]'.format(s.split('\n')[0]) log.warning('Header {} contains a newline, truncating it.'.format( ===================================== src/mailman/handlers/tests/test_cook_headers.py ===================================== --- a/src/mailman/handlers/tests/test_cook_headers.py +++ b/src/mailman/handlers/tests/test_cook_headers.py @@ -86,3 +86,26 @@ Reply-To: "A multiline [...]" <a...@example.com> More things to say. """) + + def test_non_ascii_description(self): + self._mlist.description = 'Some Coffee \u2615' + self._mlist.reply_goes_to_list = ReplyToMunging.point_to_list + msg = mfs("""\ +From: a...@example.com +To: a...@example.com +Subject: A subject +X-Mailman-Version: X.Y + +More things to say. +""") + cook_headers.process(self._mlist, msg, {}) + self.assertMultiLineEqual(msg.as_string(), """\ +From: a...@example.com +To: a...@example.com +Subject: A subject +X-Mailman-Version: X.Y +Precedence: list +Reply-To: =?utf-8?b?U29tZSBDb2ZmZWUg4piV?= <a...@example.com> + +More things to say. +""") View it on GitLab: https://gitlab.com/mailman/mailman/compare/0403f0bfc77a94656db28b6dfd1b44bea2e13881...1ead61097429bca15a9eaf87246b98bb5e34b8d2
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org