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

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:
Adam Coddington 2013-07-26 22:13:29 -07:00
parent 4c3af900c6
commit 88d122c421
5 changed files with 126 additions and 115 deletions

View file

@ -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.