[issue11050] email.utils.getaddresses behavior contradicts RFC2822

R. David Murray report at bugs.python.org
Mon May 28 21:38:25 CEST 2012


R. David Murray <rdmurray at bitdance.com> added the comment:

The pre 3.3 email package does not do any header unfolding.  You can make this work by doing the header unfolding before passing it to getaddresses:

  >>> email.utils.getaddresses([''.join(m['to'].splitlines())])
  [('A (B)', 'c at d.org'), ('', 'd at e.org')]

The new provisional policy that was just added to 3.3 (which will eventually become the standard interface) does do the unfolding before parsing the addresses, so it does not have this issue.  In 3.3 we now have this:

  >>> import email
  >>> from email.policy import SMTP
  >>> m = email.message_from_string("To: \"A\r\n (B)\" <c at d.org>, (A\r\n C) <d at e.org>\r\nSubject: test\r\n\r\nbody", policy=SMTP)
  >>> m['to'].addresses
  (Address(display_name='A (B)', username='c', domain='d.org'), Address(display_name='', username='d', domain='e.org'))

----------
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11050>
_______________________________________


More information about the Python-bugs-list mailing list