summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2012-01-15 02:33:31 +0000
committerRamiro Morales <cramm0@gmail.com>2012-01-15 02:33:31 +0000
commit665ec600a40ffc3c9baea30be9c8765939512748 (patch)
treea558e8694a93d4b97de4abc7857c71ba440ad570 /tests
parentc5dcba4159e00ed7fc43b605946be489602ab369 (diff)
Made email attachment handling code accept non-ASCII filenames.
Thanks to Anton Chaporgin for the report and to Claude Paroz for the patch. Fixes #14964. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17375 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/mail/tests.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
index 52e251f3ee..ed85918f17 100644
--- a/tests/regressiontests/mail/tests.py
+++ b/tests/regressiontests/mail/tests.py
@@ -198,6 +198,19 @@ class MailTests(TestCase):
self.assertEqual(payload[0].get_content_type(), 'multipart/alternative')
self.assertEqual(payload[1].get_content_type(), 'application/pdf')
+ def test_non_ascii_attachment_filename(self):
+ """Regression test for #14964"""
+ headers = {"Date": "Fri, 09 Nov 2001 01:08:47 -0000", "Message-ID": "foo"}
+ subject, from_email, to = 'hello', 'from@example.com', 'to@example.com'
+ content = 'This is the message.'
+ msg = EmailMessage(subject, content, from_email, [to], headers=headers)
+ # Unicode in file name
+ msg.attach(u"une pièce jointe.pdf", "%PDF-1.4.%...", mimetype="application/pdf")
+ msg_str = msg.message().as_string()
+ message = email.message_from_string(msg_str)
+ payload = message.get_payload()
+ self.assertEqual(payload[1].get_filename(), u'une pièce jointe.pdf')
+
def test_dummy_backend(self):
"""
Make sure that dummy backends returns correct number of sent messages