Issue 27513: email.utils.getaddresses does not handle Header objects
Issue27513
Created on 2016-07-14 10:50 by frispete, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| iso-8859-1-encoded-from-header.mail | frispete, 2016-07-14 10:50 | test mail | ||
| decode_from_header.py | frispete, 2016-07-14 10:56 | test program, that demonstrates the problem | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 13797 | merged | ZackerySpytz, 2019-06-04 05:59 | |
| PR 27242 | merged | miss-islington, 2021-07-19 16:08 | |
| PR 27245 | merged | miss-islington, 2021-07-19 16:56 | |
| Messages (6) | |||
|---|---|---|---|
| msg270399 - (view) | Author: Hans-Peter Jansen (frispete) * | Date: 2016-07-14 10:50 | |
An unfortunate combination of get_all and getaddresses results in a Traceback:
Traceback (most recent call last):
File "misc/decode_from_header.py", line 17, in <module>
print('From: %s' % email.utils.getaddresses(val))
File "/usr/lib64/python3.4/email/utils.py", line 112, in getaddresses
all = COMMASPACE.join(fieldvalues)
TypeError: sequence item 0: expected str instance, Header found
Here's the relevant part of it:
Content-type: text/html;charset=iso-8859-1
From: Itaú Uniclass. <comunicado.com.br@atendimento.gotdns.ch>
Obviously, the From header is iso-8859-1 encoded as well, and violates RFC 2822 as such. But making it crash in the usual combination of
val = msg.get('from')
email.utils.getaddresses([val])
isn't the real McCoy either..
|
|||
| msg270401 - (view) | Author: Hans-Peter Jansen (frispete) * | Date: 2016-07-14 10:56 | |
message.get cannot decode the header correctly, and returns a Header instance instead, which makes email.utils.getaddresses stumble upon... A much better behavior for getaddresses in this case would be returning the perfectly valid address, and ignoring the invalid dtext part. |
|||
| msg270425 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2016-07-14 16:56 | |
This appears to be something that was overlooked when btyes support was added in 3.2. getaddresses should indeed be able to handle a Header object if handed one. |
|||
| msg397812 - (view) | Author: Łukasz Langa (lukasz.langa) * ![]() |
Date: 2021-07-19 16:08 | |
New changeset 89f4c34797de2f0e5045da2b97c1c8cbbb42fbb2 by Zackery Spytz in branch 'main': bpo-27513: email.utils.getaddresses() now handles Header objects (#13797) https://github.com/python/cpython/commit/89f4c34797de2f0e5045da2b97c1c8cbbb42fbb2 |
|||
| msg397815 - (view) | Author: Łukasz Langa (lukasz.langa) * ![]() |
Date: 2021-07-19 16:55 | |
New changeset 8c43bf1a923754fa6d97772151c6ac23c48759d3 by Miss Islington (bot) in branch '3.10': bpo-27513: email.utils.getaddresses() now handles Header objects (GH-13797) (GH-27242) https://github.com/python/cpython/commit/8c43bf1a923754fa6d97772151c6ac23c48759d3 |
|||
| msg397820 - (view) | Author: Łukasz Langa (lukasz.langa) * ![]() |
Date: 2021-07-19 17:28 | |
New changeset 9ee12cf325d4da2c07919e5e56545feb7e005e08 by Miss Islington (bot) in branch '3.9': bpo-27513: email.utils.getaddresses() now handles Header objects (GH-13797) (#27245) https://github.com/python/cpython/commit/9ee12cf325d4da2c07919e5e56545feb7e005e08 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:33 | admin | set | github: 71700 |
| 2021-07-19 17:28:59 | lukasz.langa | set | messages: + msg397820 |
| 2021-07-19 16:56:41 | miss-islington | set | pull_requests: + pull_request25793 |
| 2021-07-19 16:55:54 | lukasz.langa | set | status: open -> closed stage: patch review -> resolved resolution: fixed versions: + Python 3.10, Python 3.11, - Python 3.7, Python 3.8 |
| 2021-07-19 16:55:03 | lukasz.langa | set | messages: + msg397815 |
| 2021-07-19 16:08:03 | miss-islington | set | nosy:
+ miss-islington pull_requests: + pull_request25791 |
| 2021-07-19 16:08:01 | lukasz.langa | set | nosy:
+ lukasz.langa messages: + msg397812 |
| 2019-06-04 06:01:40 | ZackerySpytz | set | nosy:
+ ZackerySpytz versions: + Python 3.7, Python 3.8, - Python 3.5, Python 3.6 |
| 2019-06-04 05:59:30 | ZackerySpytz | set | keywords:
+ patch stage: patch review pull_requests: + pull_request13682 |
| 2019-05-31 07:11:56 | Jeffrey.Kintscher | set | nosy:
+ Jeffrey.Kintscher |
| 2018-09-22 18:23:30 | xtreak | set | nosy:
+ xtreak |
| 2018-07-11 07:44:17 | serhiy.storchaka | set | type: crash -> behavior |
| 2016-07-14 16:56:41 | r.david.murray | set | title: email.utils.getaddresses raises exception from erroneous message get_all input -> email.utils.getaddresses does not handle Header objects messages: + msg270425 versions: + Python 3.5, Python 3.6, - Python 3.4 |
| 2016-07-14 10:56:08 | frispete | set | files:
+ decode_from_header.py messages: + msg270401 |
| 2016-07-14 10:50:10 | frispete | create | |
