1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

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
This commit is contained in:
Ramiro Morales
2012-01-15 02:33:31 +00:00
parent c5dcba4159
commit 665ec600a4
3 changed files with 20 additions and 1 deletions

View File

@@ -311,6 +311,10 @@ class EmailMessage(object):
mimetype = DEFAULT_ATTACHMENT_MIME_TYPE
attachment = self._create_mime_attachment(content, mimetype)
if filename:
try:
filename = filename.encode('ascii')
except UnicodeEncodeError:
filename = ('utf-8', '', filename.encode('utf-8'))
attachment.add_header('Content-Disposition', 'attachment',
filename=filename)
return attachment