Issue1025395
Created on 2004-09-09 20:43 by melicertes, last changed 2022-04-11 14:56 by admin.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 142 | closed | python-dev, 2017-02-17 19:05 | |
| PR 6917 | closed | ioanatia, 2018-05-16 19:01 | |
| Messages (10) | |||
|---|---|---|---|
| msg22413 - (view) | Author: Charles (melicertes) | Date: 2004-09-09 20:43 | |
email.Utils.parseaddr() does not successfully parse a field value into a (comment, address) pair if the address contains a source route with more than one hop. i.e., it is successfully parses this: "God" <@hop1.org:jeff@spec.org> to get the address <jeff@spec.org>, but it fails to do the same if supplied with a 2-hop source route: "God" <@hop1.org,@hop2.net:jeff@spec.org> In this case, it gets the comment ("God") right, but fails to extract the address. Multi-hop source routes, while deprecated, are still valid in rfc2822. |
|||
| msg59669 - (view) | Author: Stuart D Gathman (sdgathman) | Date: 2008-01-10 16:34 | |
# A quick and very dirty fix for common broken cases, with test cases.
import rfc822
def parseaddr(t):
"""Split email into Fullname and address.
>>> parseaddr('user@example.com')
('', 'user@example.com')
>>> parseaddr('"Full Name" <foo@example.com>')
('Full Name', 'foo@example.com')
>>> parseaddr('spam@viagra.com <foo@example.com>')
('spam@viagra.com', 'foo@example.com')
>>> parseaddr('"God" <@hop1.org,@hop2.net:jeff@spec.org>')
('God', 'jeff@spec.org')
"""
#return email.Utils.parseaddr(t)
res = rfc822.parseaddr(t)
# dirty fix for some broken cases
if not res[0]:
pos = t.find('<')
if pos > 0 and t[-1] == '>':
addrspec = t[pos+1:-1]
pos1 = addrspec.rfind(':')
if pos1 > 0:
addrspec = addrspec[pos1+1:]
return rfc822.parseaddr('"%s" <%s>' % (t[:pos].strip(),addrspec))
if not res[1]:
pos = t.find('<')
if pos > 0 and t[-1] == '>':
addrspec = t[pos+1:-1]
pos1 = addrspec.rfind(':')
if pos1 > 0:
addrspec = addrspec[pos1+1:]
return rfc822.parseaddr('%s<%s>' % (t[:pos].strip(),addrspec))
return res
|
|||
| msg59670 - (view) | Author: Stuart D Gathman (sdgathman) | Date: 2008-01-10 16:37 | |
Ok, I see the '@' is technically not allowed in an atom. But it either needs to throw an invalid syntax exception, or heuristically return something reasonable. |
|||
| msg59671 - (view) | Author: Stuart D Gathman (sdgathman) | Date: 2008-01-10 16:39 | |
Repeating because previous real life test case was rejected as 'spam':
It also fails to parse:
>>> from email.Utils import parseaddr
>>> parseaddr('foo@spammer.com <bar@baz.com>')
('', 'foo@spammer.com')
Getting the wrong part as the actual email to boot! Checked 2.4 and 2.5.
|
|||
| msg59735 - (view) | Author: Stuart D Gathman (sdgathman) | Date: 2008-01-11 19:08 | |
Same or related issues: Issue1221, Issue1409460 |
|||
| msg59737 - (view) | Author: Stuart D Gathman (sdgathman) | Date: 2008-01-11 19:14 | |
Test cases so far:
>>> parseaddr('user@example.com')
('', 'user@example.com')
>>> parseaddr('"Full Name" <foo@example.com>')
('Full Name', 'foo@example.com')
>>> parseaddr('spam@spammer.com <foo@example.com>')
('spam@spammer.com', 'foo@example.com')
>>> parseaddr('God@heaven <@hop1.org,@hop2.net:jeff@spec.org>')
('God@heaven', 'jeff@spec.org')
>>> parseaddr('Real Name ((comment)) <addr...@example.com>')
('Real Name', 'addr...@example.com')
>>> parseaddr('a(WRONG)@b')
('', 'a@b')
|
|||
| msg59751 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2008-01-11 21:18 | |
An example from #1221: >>> email.Utils.parseaddr("a(WRONG)@b") ('WRONG WRONG', 'a@b') |
|||
| msg59753 - (view) | Author: Stuart D Gathman (sdgathman) | Date: 2008-01-11 21:21 | |
tiran: yes, but that is the wrong answer, and that example is already in the testcase list (with what I believe is the right answer). |
|||
| msg301485 - (view) | Author: Alexander Mohr (thehesiod) * | Date: 2017-09-06 16:59 | |
from 3.6:
>>> AddrlistClass('John Smith <john.smith(comment)@example.org>').getcomment()
''
>>> AddrlistClass('John Smith <john.smith(comment)@example.org>').getdomain()
'JohnSmith'
totally messed up :)
|
|||
| msg301504 - (view) | Author: Alexander Mohr (thehesiod) * | Date: 2017-09-06 19:45 | |
looks like these were meant to be internal methods, retracting new issues |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:06 | admin | set | github: 40889 |
| 2018-05-16 19:01:00 | ioanatia | set | keywords:
+ patch stage: test needed -> patch review pull_requests: + pull_request6585 |
| 2017-09-06 19:45:23 | thehesiod | set | messages: + msg301504 |
| 2017-09-06 16:59:51 | thehesiod | set | messages: + msg301485 |
| 2017-09-06 16:57:36 | thehesiod | set | nosy:
+ thehesiod versions: + Python 3.6, Python 3.7 |
| 2017-03-27 08:36:43 | ioanatia | set | nosy:
+ ioanatia |
| 2017-02-17 19:05:34 | python-dev | set | pull_requests: + pull_request103 |
| 2017-02-09 11:49:27 | sascha_silbe | set | nosy:
+ sascha_silbe |
| 2014-07-25 13:01:28 | martin.panter | set | nosy:
+ martin.panter |
| 2012-05-16 01:57:28 | r.david.murray | set | assignee: r.david.murray -> components: + email versions: - Python 3.1 |
| 2011-03-14 03:26:43 | r.david.murray | set | nosy:
barry, melicertes, christian.heimes, sdgathman, eric.araujo, r.david.murray versions: + Python 3.3 |
| 2010-12-27 18:26:58 | r.david.murray | set | nosy:
barry, melicertes, christian.heimes, sdgathman, eric.araujo, r.david.murray versions: + Python 3.1, Python 3.2 |
| 2010-07-17 11:44:39 | eric.araujo | set | nosy:
+ eric.araujo |
| 2010-05-05 13:40:29 | barry | set | assignee: barry -> r.david.murray nosy: + r.david.murray |
| 2009-07-04 02:42:37 | ezio.melotti | set | stage: test needed versions: + Python 2.7, - Python 2.5, Python 2.4, Python 2.3 |
| 2008-01-28 08:33:42 | loewis | set | messages: - msg59668 |
| 2008-01-11 21:21:47 | sdgathman | set | messages: + msg59753 |
| 2008-01-11 21:18:31 | christian.heimes | link | issue1221 superseder |
| 2008-01-11 21:18:11 | christian.heimes | set | nosy:
+ christian.heimes messages: + msg59751 |
| 2008-01-11 19:14:26 | sdgathman | set | messages: + msg59737 |
| 2008-01-11 19:08:47 | sdgathman | set | messages: + msg59735 |
| 2008-01-10 16:39:04 | sdgathman | set | messages: + msg59671 |
| 2008-01-10 16:37:37 | sdgathman | set | messages: + msg59670 |
| 2008-01-10 16:34:08 | sdgathman | set | messages: + msg59669 |
| 2008-01-10 16:22:47 | sdgathman | set | type: behavior |
| 2008-01-10 16:22:18 | sdgathman | set | nosy:
+ sdgathman messages: + msg59668 versions: + Python 2.5, Python 2.4 |
| 2004-09-09 20:43:42 | melicertes | create | |
