From cc40023ca0498609c37d37d42fa21e822e15dc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Mon, 21 Oct 2013 10:18:54 -0300 Subject: Default to UTF-8 when there is not charset parsed from the mail contents --- mail/changes/bug_default_to_utf8 | 2 ++ mail/src/leap/mail/imap/server.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 mail/changes/bug_default_to_utf8 (limited to 'mail') diff --git a/mail/changes/bug_default_to_utf8 b/mail/changes/bug_default_to_utf8 new file mode 100644 index 0000000..898138b --- /dev/null +++ b/mail/changes/bug_default_to_utf8 @@ -0,0 +1,2 @@ + o Default to UTF-8 when there is no charset parsed from the mail + contents. \ No newline at end of file diff --git a/mail/src/leap/mail/imap/server.py b/mail/src/leap/mail/imap/server.py index 10d338a..df510ce 100644 --- a/mail/src/leap/mail/imap/server.py +++ b/mail/src/leap/mail/imap/server.py @@ -711,6 +711,8 @@ class LeapMessage(WithMsgFields): # Miniparser for: Content-Type: ; charset= charset_re = r'''charset=(?P[\w|\d|-]*)''' charset = re.findall(charset_re, em["Content-Type"])[0] + if charset is None or len(charset) == 0: + charset = "UTF-8" except Exception: pass return charset -- cgit v1.2.3