From 7de9b2d96cfdf562ba50c1a39c433809007f9e2a Mon Sep 17 00:00:00 2001 From: Robert Schroll Date: Tue, 30 Apr 2013 13:47:01 -0700 Subject: [PATCH] Set Content-Transfer-Encoding for text: Closes #6377, Closes #6378 By using GMime's set_best_content_encoding(), Geary will use an appropriate Content-Transfer-Encoding for the block of data being transmitted (plain body, HTML body, attachments). Using this also deals with encoding long line lengths properly. Note that #6842 is still a problem (properly encoding emails forwarded as attachments). --- src/client/util/util-webkit.vala | 4 ++-- src/engine/rfc822/rfc822-message.vala | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/util/util-webkit.vala b/src/client/util/util-webkit.vala index 98c18139..14f89abc 100644 --- a/src/client/util/util-webkit.vala +++ b/src/client/util/util-webkit.vala @@ -253,8 +253,8 @@ public string html_to_flowed_text(WebKit.DOM.Document doc) { } } - // Reassemble plain text out of parts - string doctext = resolve_nesting(doc.get_body().get_inner_text(), bqtexts); + // Reassemble plain text out of parts, replace non-breaking space with regular space + string doctext = resolve_nesting(doc.get_body().get_inner_text(), bqtexts).replace("\xc2\xa0", " "); // Reassemble DOM for (int i = 0; i < nbq; i++) { diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala index 7b42702f..42120de6 100644 --- a/src/engine/rfc822/rfc822-message.vala +++ b/src/engine/rfc822/rfc822-message.vala @@ -119,6 +119,8 @@ public class Geary.RFC822.Message : BaseObject { body_text = new GMime.Part(); body_text.set_content_type(new GMime.ContentType.from_string("text/plain; charset=utf-8; format=flowed")); body_text.set_content_object(content); + body_text.set_content_encoding(body_text.get_best_content_encoding( + GMime.EncodingConstraint.7BIT)); } // Body: HTML format (also optional) @@ -131,6 +133,8 @@ public class Geary.RFC822.Message : BaseObject { body_html = new GMime.Part(); body_html.set_content_type(new GMime.ContentType.from_string("text/html; charset=utf-8")); body_html.set_content_object(content); + body_html.set_content_encoding(body_html.get_best_content_encoding( + GMime.EncodingConstraint.7BIT)); } // Build the message's mime part. @@ -245,7 +249,7 @@ public class Geary.RFC822.Message : BaseObject { part.set_content_object(new GMime.DataWrapper.with_stream(stream, GMime.ContentEncoding.BINARY)); // This encoding is the "Content-Transfer-Encoding", which GMime automatically converts to. - part.set_content_encoding(GMime.ContentEncoding.BASE64); + part.set_content_encoding(part.get_best_content_encoding(GMime.EncodingConstraint.7BIT)); return part; }