If we cant decode using the body charset, try to decode using utf8. (#4)
If we can't decode using the body charset, try to decode using utf8. Change the way we get the cahrset. Task #159072
This commit is contained in:
parent
facc433a8b
commit
916a3d9d96
10
utils.py
10
utils.py
|
@ -3,10 +3,12 @@ import bleach
|
|||
def render_email(eml):
|
||||
body = eml.get_body(['html', 'plain'])
|
||||
if body:
|
||||
charset = body.get_content_charset()
|
||||
if not charset:
|
||||
charset = 'utf-8'
|
||||
html = body.get_payload(decode=True).decode(charset)
|
||||
charset = body.get_content_charset('utf-8')
|
||||
try:
|
||||
html = body.get_payload(decode=True).decode(charset)
|
||||
except:
|
||||
# If the charset returns an error, try utf-8
|
||||
html = body.get_payload(decode=True).decode('utf-8')
|
||||
else:
|
||||
html = ''
|
||||
images = {}
|
||||
|
|
Loading…
Reference in New Issue