From 48a9aaebf4eba44818be7f9f3e975143d4213143 Mon Sep 17 00:00:00 2001 From: medmunds Date: Wed, 5 Aug 2020 11:44:14 -0700 Subject: [PATCH] (Cherry pick v7.2.1) --- CHANGELOG.rst | 13 +++++++++++++ tests/test_inbound.py | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9db47d0..32457c0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -49,6 +49,18 @@ Breaking changes `mixin superclass ordering `__.) +v7.2.1 +------ + +*2020-08-05* + +Fixes +~~~~~ + +* **Inbound:** Fix a Python 2.7-only UnicodeEncodeError when attachments have non-ASCII + filenames. (Thanks to `@kika115`_ for reporting it.) + + v7.2 LTS -------- @@ -1123,6 +1135,7 @@ Features .. _@janneThoft: https://github.com/janneThoft .. _@jc-ee: https://github.com/jc-ee .. _@joshkersey: https://github.com/joshkersey +.. _@kika115: https://github.com/kika115 .. _@Lekensteyn: https://github.com/Lekensteyn .. _@lewistaylor: https://github.com/lewistaylor .. _@mbk-ok: https://github.com/mbk-ok diff --git a/tests/test_inbound.py b/tests/test_inbound.py index 7dd1c05..d3eb26f 100644 --- a/tests/test_inbound.py +++ b/tests/test_inbound.py @@ -134,6 +134,15 @@ class AnymailInboundMessageConstructionTests(SimpleTestCase): att = AnymailInboundMessage.construct_attachment(content_type="image/png", content=content, base64=True) self.assertEqual(att.get_content_bytes(), SAMPLE_IMAGE_CONTENT) + def test_construct_attachment_unicode_filename(self): + # Issue #197 + att = AnymailInboundMessage.construct_attachment( + content_type="text/plain", content="Unicode ✓", charset='utf-8', base64=False, + filename="Simulácia.txt", content_id="inline-id",) + self.assertEqual(att.get_filename(), "Simulácia.txt") + self.assertTrue(att.is_inline_attachment()) + self.assertEqual(att.get_content_text(), "Unicode ✓") + def test_parse_raw_mime(self): # (we're not trying to exhaustively test email.parser MIME handling here; # just that AnymailInboundMessage.parse_raw_mime calls it correctly)