fix(email): handle case where cstr returns text_type of str

chardet requires input to be bytes or bytesarray, but sometimes
frappe.cstr() returns text_type of str without encoding it to utf-8

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
This commit is contained in:
Chinmay D. Pai 2019-12-27 16:11:31 +05:30
parent 1bd0cfdfde
commit 4d48a2a032
No known key found for this signature in database
GPG key ID: 75507BE256F40CED

View file

@ -480,7 +480,7 @@ class Email:
"""Detect chartset."""
charset = part.get_content_charset()
if not charset:
charset = chardet.detect(cstr(part))['encoding']
charset = chardet.detect(safe_encode(cstr(part)))['encoding']
return charset