From d75d838e26011cb2854314549ce5e0db7e3c24b0 Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Wed, 18 May 2016 12:57:56 -0700 Subject: [PATCH] [#97] Do not attempt to convert filename top unicode if no filename was available. --- 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 8121486..c1af304 100644 --- a/django_mailbox/models.py +++ b/django_mailbox/models.py @@ -260,7 +260,10 @@ class Mailbox(models.Model): ) or ('attachment' in msg.get('Content-Disposition', '')) ): - filename = utils.convert_header_to_unicode(msg.get_filename()) + filename = None + raw_filename = msg.get_filename() + if raw_filename: + filename = utils.convert_header_to_unicode(raw_filename) if not filename: extension = mimetypes.guess_extension(msg.get_content_type()) else: