[geary] Always use UTF-8 for encoding non-ASCII/ISO-8859-1 headers. Bug 753870.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Always use UTF-8 for encoding non-ASCII/ISO-8859-1 headers. Bug 753870.
- Date: Thu, 30 Jun 2016 07:35:41 +0000 (UTC)
commit f10f898ab0c9dfeaeac82a5f969dbc8e0d3512c3
Author: Michael James Gratton <mike vee net>
Date: Thu Jun 30 15:29:39 2016 +1000
Always use UTF-8 for encoding non-ASCII/ISO-8859-1 headers. Bug 753870.
While message bodies are always sent as UTF-8, non ASCII/ISO-8859-1
headers were being encoded using GMime's default heuristics. This
uses some less-well-supported charsets and causing some rendering
issues in other less tolerant client.
Since we assume UTF-8 support for the body, assume it for headers as
well.
* src/engine/rfc822/rfc822.vala (Geary.RFC822.init): Set GMime user
charsets to UTF-8.
* bindings/vapi/gmime-2.6.vapi (GMime): Fix binding for
g_mime_set_user_charsets.
bindings/vapi/gmime-2.6.vapi | 2 +-
src/engine/rfc822/rfc822.vala | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/bindings/vapi/gmime-2.6.vapi b/bindings/vapi/gmime-2.6.vapi
index 59c6909..0bb1991 100644
--- a/bindings/vapi/gmime-2.6.vapi
+++ b/bindings/vapi/gmime-2.6.vapi
@@ -1342,7 +1342,7 @@ namespace GMime {
[CCode (cheader_filename = "gmime/gmime.h", cname = "g_mime_locale_language")]
public static unowned string locale_language ();
[CCode (cheader_filename = "gmime/gmime.h", cname = "g_mime_set_user_charsets")]
- public static void set_user_charsets (out unowned string charsets);
+ public static void set_user_charsets ([CCode (array_length = false)] string[] charsets);
[CCode (cheader_filename = "gmime/gmime.h", cname = "g_mime_shutdown")]
public static void shutdown ();
[CCode (cheader_filename = "gmime/gmime.h", cname = "g_mime_user_charsets")]
diff --git a/src/engine/rfc822/rfc822.vala b/src/engine/rfc822/rfc822.vala
index f625671..b09376a 100644
--- a/src/engine/rfc822/rfc822.vala
+++ b/src/engine/rfc822/rfc822.vala
@@ -14,6 +14,11 @@ public enum TextFormat {
HTML
}
+// This has the effect of ensuring all non US-ASCII and non-ISO-8859-1
+// headers are always encoded as UTF-8. This should be fine because
+// message bodies are also always sent as UTF-8.
+private const string[] USER_CHARSETS = { "UTF-8" };
+
private int init_count = 0;
internal Regex? invalid_filename_character_re = null;
@@ -21,9 +26,10 @@ internal Regex? invalid_filename_character_re = null;
public void init() {
if (init_count++ != 0)
return;
-
+
GMime.init(GMime.ENABLE_RFC2047_WORKAROUNDS);
-
+ GMime.set_user_charsets(USER_CHARSETS);
+
try {
invalid_filename_character_re = new Regex("[/\\0]");
} catch (RegexError e) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]