Ticket #14964: mail_attachment.diff
File mail_attachment.diff, 1.1 KB (added by , 14 years ago) |
---|
-
core/mail/message.py
11 11 12 12 from django.conf import settings 13 13 from django.core.mail.utils import DNS_NAME 14 from django.utils.encoding import smart_str, force_unicode 14 from django.utils.encoding import smart_str, force_unicode, iri_to_uri 15 15 16 16 # Don't BASE64-encode UTF-8 messages so that we avoid unwanted attention from 17 17 # some spam filters. … … 249 249 mimetype = DEFAULT_ATTACHMENT_MIME_TYPE 250 250 attachment = self._create_mime_attachment(content, mimetype) 251 251 if filename: 252 attachment.add_header('Content-Disposition', 'attachment', 253 filename=filename) 252 if all(ord(c) < 128 for c in filename): 253 params = {'filename': filename} 254 else: 255 params = {'filename': "UTF-8''%s" % iri_to_uri(filename)}} 256 attachment.add_header('Content-Disposition', 'attachment',**params) 254 257 return attachment 255 258 256 259