This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: email.Utils.formataddr doesn't handle whitespace too well
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, doko
Priority: normal Keywords:

Created on 2004-01-12 20:30 by doko, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg19641 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-01-12 20:30
[forwarded from http://bugs.debian.org/178777]

originally reported for mailman, then reassigned to python

It seems like this problem is because
email.Utils.formataddr doesn't
handle newlines embedded in headers too well.

: tfheen@yiwaz ..man/mailman-2.1.3/Mailman > python
Python 2.3.3a0 (#2, Nov 21 2003, 00:36:53) 
[GCC 3.3.2 (Debian)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> from email.Utils import formataddr
>>> formataddr(("Books is a list for discussing all
aspects of the audio\nand text boox",
'books@spanky.braille.uwo.ca')) 'Books is a list for
discussing all aspects of the audio\nand text boox
<books@spanky.braille.uwo.ca>'
>>> 

IMHO, it should either strip newlines or at least
insert a space in front of them so they aren't
interpreted as a new header.

msg19642 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-05-10 22:20
Logged In: YES 
user_id=12800

It's questionable whether formataddr should do this or not.
 Its docstring could be interpreted either way ('suitable
for an RFC 2822 [...] header').

My inclination is to keep the magic out of formataddr and
leave it up to the application to sanitize the real name. 
I'm closing this as won't fix, but if you still disagree,
feel free to bring it up on the email-sig.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39806
2004-01-12 20:30:58dokocreate