Issue28122
Created on 2016-09-13 08:49 by sijian liang, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files |
|
|
|
| File name |
Uploaded |
Description |
Edit |
| demo.py |
sijian liang,2016-09-13 08:49 |
|
|
| Messages (3) |
|
|
| msg276214 - (view) |
Author: sijian liang (sijian liang) |
Date: 2016-09-13 08:51 |
| #!/usr/bin/python #-*- coding:utf-8 -*- import email # from email.parser import Parser def decode_email_header(header, sep=''): l = [] for s, c in header: if c: l.append(s.decode(c)) else: l.append(s) return sep.join(l) s = email.Header.decode_header('"=?gb18030?B?bWFpbGZvcnRlc3R0?=" <2070776562@qq.com>') print decode_email_header(s) s = email.Header.decode_header('=?gb18030?B?bWFpbGZvcnRlc3R0?= <2070776562@qq.com>') print decode_email_header(s) # see output: # "=?gb18030?B?bWFpbGZvcnRlc3R0?=" <2070776562@qq.com> # mailfortestt<2070776562@qq.com> |
|
|
| msg276236 - (view) |
Author: (era) |
Date: 2016-09-13 10:05 |
| The double quotes around the "human readable" part of the email address are not allowed. Python is handling this correctly. |
|
|
| msg276320 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2016-09-13 18:42 |
| Note, however, that python3 will compensate for this bug in the input, and register a defect for it: >>> import email >>> import email.policy >>> msg = email.message_from_string('To: "=?gb18030?B?bWFpbGZvcnRlc3R0?=" <2070776562@qq.com>\n\ntest body', policy=email.policy.default) >>> print(msg) To: "=?gb18030?B?bWFpbGZvcnRlc3R0?=" <2070776562@qq.com> test body >>> msg['To'] 'mailfortestt <2070776562@qq.com>' >>> msg['To'].defects (InvalidHeaderDefect('encoded word inside quoted string',),) |
|
|
| History |
|
|
|
| Date |
User |
Action |
Args |
| 2022-04-11 14:58:36 |
admin |
set |
github: 72309 |
| 2016-09-13 18:42:23 |
r.david.murray |
set |
status: open -> closedresolution: out of datemessages: + stage: resolved |
| 2016-09-13 10:05:20 |
era |
set |
nosy: + eramessages: + |
| 2016-09-13 08:51:52 |
sijian liang |
set |
messages: + |
| 2016-09-13 08:49:33 |
sijian liang |
create |
|