forked from mirror/django-mailbox
Base64-encode message body when storing in DB.
* Since Django requires that the content stored in a TextField be unicode, we need some way to encode the message safely. In situations before where a single-byte non-7-bit-clean encoding were used, django-mailbox could explode when writing the message copy to the database; this should ameliorate that problem. * Reverts earlier changesets' encoding normalization.
This commit is contained in:
parent
4c3af900c6
commit
88d122c421
5 changed files with 126 additions and 115 deletions
|
|
@ -2,6 +2,7 @@ import email
|
|||
import os.path
|
||||
|
||||
from django.test import TestCase
|
||||
import sys
|
||||
|
||||
from django_mailbox import models
|
||||
from django_mailbox.models import Mailbox, Message
|
||||
|
|
@ -28,11 +29,12 @@ class EmailMessageTestCase(TestCase):
|
|||
'messages',
|
||||
name,
|
||||
),
|
||||
'r'
|
||||
'rb'
|
||||
) as f:
|
||||
return email.message_from_string(
|
||||
f.read()
|
||||
)
|
||||
if sys.version_info < (3, 0):
|
||||
return email.message_from_string(f.read())
|
||||
else:
|
||||
return email.message_from_bytes(f.read())
|
||||
|
||||
def _headers_identical(self, left, right, header=None):
|
||||
""" Check if headers are (close enough to) identical.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue