Skip to content

Commit ec9accb

Browse files
committed
fixed encoding issues in mailer
1 parent 98aa9ea commit ec9accb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

roundup/mailer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from email.mime.multipart import MIMEMultipart
1616

1717
from roundup.anypy import email_
18-
from roundup.anypy.strings import s2u
18+
from roundup.anypy.strings import b2s, s2u
1919

2020
try:
2121
import pyme, pyme.core
@@ -39,7 +39,7 @@ def nice_sender_header(name, address, charset):
3939
if not name:
4040
return address
4141
try:
42-
encname = name.encode('ASCII')
42+
encname = b2s(name.encode('ASCII'))
4343
except UnicodeEncodeError:
4444
# use Header to encode correctly.
4545
encname = Header(name, charset=charset).encode()

test/test_mailer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ def testEncoding(self):
1010
a('ascii', '[email protected]', 'iso8859-1', 'ascii <[email protected]>')
1111
a(u'café', '[email protected]', 'iso8859-1',
1212
'=?iso8859-1?q?caf=E9?= <[email protected]>')
13+
a(u'café', '[email protected]', 'utf-8',
14+
'=?utf-8?b?Y2Fmw6k=?= <[email protected]>')
1315
a('as"ii', '[email protected]', 'iso8859-1', '"as\\"ii" <[email protected]>')
1416

1517
# vim: set et sts=4 sw=4 :

0 commit comments

Comments
 (0)