[issue34155] email.utils.parseaddr mistakenly parse an email
Windson Yang
report at bugs.python.org
Thu May 2 21:45:21 EDT 2019
Windson Yang <wiwindson at outlook.com> added the comment:
I found the issue located in https://github.com/python/cpython/blob/master/Lib/email/_parseaddr.py#L277
elif self.field[self.pos] in '.@':
# email address is just an addrspec
# this isn't very efficient since we start over
self.pos = oldpos
self.commentlist = oldcl
addrspec = self.getaddrspec()
returnlist = [(SPACE.join(self.commentlist), addrspec)]
The parseaddr function runs a for in loop over the input string, when it meets '.@' it will do something. That is why when the input string is 'foo at bar.com@example.com' will return ('', 'foo at bar.com'). One possible solution will be to check the string in the reverse order then we can always get the last '@' in the string.
----------
nosy: +Windson Yang
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34155>
_______________________________________
More information about the Python-bugs-list
mailing list