Message347598
Maybe a solution, if no charset defined, then encode it as utf-8 in decode_header, because it's Python3's default encoding?
diff --git a/Lib/email/header.py b/Lib/email/header.py
index 4ab0032bc6..8dbfe58a57 100644
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -135,7 +135,10 @@ def decode_header(header):
collapsed = []
last_word = last_charset = None
for word, charset in decoded_words:
- if isinstance(word, str):
+ if not charset and isinstance(word, str):
+ word = word.encode('utf-8')
+ charset = 'utf-8'
+ elif isinstance(word, str):
word = bytes(word, 'raw-unicode-escape')
if last_word is None:
last_word = word
Python 3.9.0a0 (heads/master:110a47c4f4, Jul 10 2019, 11:32:53)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.header
>>> header = "Your booking at Voyager Int'l Hostel,=?UTF-8?B?IFBhbmFtw6EgQ2l0eQ==?=, Panamá- Casco Antiguo"
>>> print(email.header.make_header(email.header.decode_header(header)))
Your booking at Voyager Int'l Hostel, Panamá City, Panamá- Casco Antiguo
>>> |
|
Date |
User |
Action |
Args |
2019-07-10 04:36:50 | aldwinaldwin | set | recipients:
+ aldwinaldwin, barry, r.david.murray, yunlee |
2019-07-10 04:36:50 | aldwinaldwin | set | messageid: <1562733410.07.0.879647794751.issue37532@roundup.psfhosted.org> |
2019-07-10 04:36:50 | aldwinaldwin | link | issue37532 messages |
2019-07-10 04:36:49 | aldwinaldwin | create | |
|