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.
This commit is contained in:
Michael James Gratton 2016-06-30 15:29:39 +10:00
parent 7166c15ea3
commit f10f898ab0
2 changed files with 9 additions and 3 deletions

View file

@ -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")]

View file

@ -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;
@ -23,6 +28,7 @@ public void init() {
return;
GMime.init(GMime.ENABLE_RFC2047_WORKAROUNDS);
GMime.set_user_charsets(USER_CHARSETS);
try {
invalid_filename_character_re = new Regex("[/\\0]");