From a00f8371506ac1e2eefbba8bd867597f8431fc2f Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Sat, 14 May 2016 22:29:23 -0700 Subject: [PATCH] Return unicode-converted filename only if a response was returned. --- django_mailbox/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django_mailbox/models.py b/django_mailbox/models.py index fe99ce0..affaa7a 100644 --- a/django_mailbox/models.py +++ b/django_mailbox/models.py @@ -724,7 +724,10 @@ class MessageAttachment(models.Model): """Returns the original filename of this attachment.""" file_name = self._get_rehydrated_headers().get_filename() if isinstance(file_name, six.text_type): - return utils.convert_header_to_unicode(file_name) + result = utils.convert_header_to_unicode(file_name) + if result is None: + return file_name + return result else: return None