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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user