1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

[#130] Taking default_charset into account for base64-encoded values is not necessary.

This commit is contained in:
Adam Coddington 2017-03-05 21:40:58 -08:00
parent 2df2d8a4fc
commit 13abec2e68

View file

@ -642,12 +642,8 @@ class Message(models.Model):
if they are encoded as such. if they are encoded as such.
""" """
settings = utils.get_settings()
if self.encoded: if self.encoded:
return base64.b64decode( return base64.b64decode(self.body.encode('ascii'))
self.body.encode(settings['default_charset'], 'replace')
)
return self.body.encode('utf-8') return self.body.encode('utf-8')
def set_body(self, body): def set_body(self, body):
@ -658,16 +654,11 @@ class Message(models.Model):
no fields existed for storing arbitrary bytes. no fields existed for storing arbitrary bytes.
""" """
settings = utils.get_settings()
if six.PY3 and isinstance(body, six.text_type): if six.PY3 and isinstance(body, six.text_type):
body = body.encode('utf-8') body = body.encode('utf-8')
self.encoded = True self.encoded = True
self.body = base64.b64encode(body).decode( self.body = base64.b64encode(body).decode('ascii')
settings['default_charset'],
'replace',
)
def get_email_object(self): def get_email_object(self):
"""Returns an `email.message.Message` instance representing the """Returns an `email.message.Message` instance representing the