pst: account for possible failure in decoding body and possible "unicode" name for encoding

This commit is contained in:
Jean-Francois Dockes 2021-10-19 09:53:59 +02:00
parent 1f92478daf
commit 1d158f329a

View File

@ -135,8 +135,13 @@ class EmailBuilder(object):
charset = headers.get_content_charset() charset = headers.get_content_charset()
body = '' body = ''
if charset: if charset:
body = self.body.decode(charset, errors='replace') if charset == 'unicode':
#self.log("DECODE FROM HEADER CHARSET %s SUCCEEDED"% charset) charset = 'utf-16'
try:
body = self.body.decode(charset, errors='replace')
#self.log("DECODE FROM HEADER CHARSET %s SUCCEEDED"% charset)
except:
pass
else: else:
try: try:
body = self.body.decode('utf-8') body = self.body.decode('utf-8')