IMAP.py __savemessage_fetchheaders decode bytes

This patch changes the function __savemessage_fetchheaders to decode the
bytes retunred by imaplib2.

We need a list of headers, with string values, but imapli2 is providing
a list with bytes. This change convert the values to str.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
This commit is contained in:
Rodolfo García Peñas (kix) 2020-09-03 19:10:06 +02:00
parent b24687fcd6
commit df4b9174d7

View File

@ -477,6 +477,9 @@ class IMAPFolder(BaseFolder):
# ('185 (RFC822.HEADER {1789}', '... mail headers ...'), ' UID 2444)' # ('185 (RFC822.HEADER {1789}', '... mail headers ...'), ' UID 2444)'
for item in result: for item in result:
if found is None and type(item) == tuple: if found is None and type(item) == tuple:
# Decode the value
item = [x.decode('utf-8') for x in item]
# Walk just tuples. # Walk just tuples.
if re.search("(?:^|\\r|\\n)%s:\s*%s(?:\\r|\\n)" % (headername, headervalue), if re.search("(?:^|\\r|\\n)%s:\s*%s(?:\\r|\\n)" % (headername, headervalue),
item[1], flags=re.IGNORECASE): item[1], flags=re.IGNORECASE):