Ticket #11144: bug11144.patch

File bug11144.patch, 1002 bytes (added by rmt, 6 years ago)

Use email.Utils.getaddresses instead of toaddrstring.split(",")

  • django/core/mail.py

    diff --git a/django/core/mail.py b/django/core/mail.py
    index 6a45b46..677d59f 100644
    a b from email.MIMEText import MIMEText 
    1313from email.MIMEMultipart import MIMEMultipart
    1414from email.MIMEBase import MIMEBase
    1515from email.Header import Header
    16 from email.Utils import formatdate, parseaddr, formataddr
     16from email.Utils import formatdate, parseaddr, formataddr, getaddresses
    1818from django.conf import settings
    1919from django.utils.encoding import smart_str, force_unicode
    def forbid_multi_line_headers(name, val): 
    7979    except UnicodeEncodeError:
    8080        if name.lower() in ('to', 'from', 'cc'):
    8181            result = []
    82             for item in val.split(', '):
    83                 nm, addr = parseaddr(item)
     82            for nm,addr in getaddresses( (val,) ):
    8483                nm = str(Header(nm, settings.DEFAULT_CHARSET))
    8584                result.append(formataddr((nm, str(addr))))
    8685            val = ', '.join(result)
Back to Top