Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not forcefully convert the payload to ASCII base on the assumption that it should be encoded in base64. #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion repoze/sendmail/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def encode_message(message,
The return is a byte string of the whole message.
"""
cleanup_message(message)
return message.as_string().encode('ascii')
return message.as_string()


def best_charset(text):
Expand Down
14 changes: 14 additions & 0 deletions repoze/sendmail/tests/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@ def test_encoding_utf_8_body(self):

self.assertTrue(encodestring(body.encode('utf-8')) in encoded)

def test_encoding_raw_utf_8_body(self):
from repoze.sendmail._compat import b
from repoze.sendmail._compat import encodestring
utf_8_encoded = b('mo \xe2\x82\xac')
utf_8 = utf_8_encoded.decode('utf-8')
body = 'I know what you did last '+ utf_8
message = self._makeMessage()
message['Content-Transfer-Encoding'] = '8bit'
message.set_payload(body)

encoded = self._callFUT(message)

self.assertTrue(body.encode('utf-8') in encoded)

def test_binary_body(self):
from email.mime import application
from email.mime import multipart
Expand Down