Mercurial > p > roundup > code
changeset 5458:bc2e682e0305
fixed encoding issues in mailer
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Mon, 23 Jul 2018 22:21:52 +0100 |
| parents | a35d4cc8cd1a |
| children | 52ff4c59fb05 |
| files | roundup/mailer.py test/test_mailer.py |
| diffstat | 2 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/mailer.py Mon Jul 23 21:45:05 2018 +0100 +++ b/roundup/mailer.py Mon Jul 23 22:21:52 2018 +0100 @@ -15,7 +15,7 @@ from email.mime.multipart import MIMEMultipart from roundup.anypy import email_ -from roundup.anypy.strings import s2u +from roundup.anypy.strings import b2s, s2u try: import pyme, pyme.core @@ -39,7 +39,7 @@ if not name: return address try: - encname = name.encode('ASCII') + encname = b2s(name.encode('ASCII')) except UnicodeEncodeError: # use Header to encode correctly. encname = Header(name, charset=charset).encode()
--- a/test/test_mailer.py Mon Jul 23 21:45:05 2018 +0100 +++ b/test/test_mailer.py Mon Jul 23 22:21:52 2018 +0100 @@ -10,6 +10,8 @@ a('ascii', 'ascii@test.com', 'iso8859-1', 'ascii <ascii@test.com>') a(u'café', 'ascii@test.com', 'iso8859-1', '=?iso8859-1?q?caf=E9?= <ascii@test.com>') + a(u'café', 'ascii@test.com', 'utf-8', + '=?utf-8?b?Y2Fmw6k=?= <ascii@test.com>') a('as"ii', 'ascii@test.com', 'iso8859-1', '"as\\"ii" <ascii@test.com>') # vim: set et sts=4 sw=4 :
