Fix format=flowed when sending Base64 encoded text/plain. Bug 753528.
Sending a message with a text/plain body containing many wide chars will usually result in it being encoded as Base64. This was breaking format=flowed since Geary was doing the LF=>CRLF conversion only when serialisaing for transmission, so the LF's in the unencoded text were not getting converted to CRLF, and hence all the line breaks were interpreted as hard breaks under F=F. * src/engine/rfc822/rfc822-message.vala (Message.from_composed_email): When setting the RFC822 message body/body part from the composed message, apply a CRLF filter first iff it will be encoded with Base64.
This commit is contained in:
parent
f10f898ab0
commit
da96e96c70
1 changed files with 17 additions and 7 deletions
|
|
@ -145,17 +145,27 @@ public class Geary.RFC822.Message : BaseObject {
|
|||
// Body: text format (optional)
|
||||
GMime.Part? body_text = null;
|
||||
if (email.body_text != null) {
|
||||
GMime.StreamMem stream = new GMime.StreamMem.with_buffer(email.body_text.data);
|
||||
GMime.DataWrapper content = new GMime.DataWrapper.with_stream(stream,
|
||||
GMime.ContentEncoding.DEFAULT);
|
||||
|
||||
GMime.Stream stream = new GMime.StreamMem.with_buffer(email.body_text.data);
|
||||
GMime.ContentEncoding encoding = Geary.RFC822.Utils.get_best_content_encoding(
|
||||
stream, GMime.EncodingConstraint.7BIT
|
||||
);
|
||||
if (encoding == GMime.ContentEncoding.BASE64) {
|
||||
// Base64-encoded text needs to have CR's added after
|
||||
// LF's before encoding, otherwise it breaks
|
||||
// format=flowed. See bug 753528.
|
||||
GMime.StreamFilter filter_stream = new GMime.StreamFilter(stream);
|
||||
filter_stream.add(new GMime.FilterCRLF(true, false));
|
||||
stream = filter_stream;
|
||||
}
|
||||
GMime.DataWrapper content = new GMime.DataWrapper.with_stream(
|
||||
stream, GMime.ContentEncoding.DEFAULT
|
||||
);
|
||||
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(Geary.RFC822.Utils.get_best_content_encoding(stream,
|
||||
GMime.EncodingConstraint.7BIT));
|
||||
body_text.set_content_encoding(encoding);
|
||||
}
|
||||
|
||||
|
||||
// Body: HTML format (also optional)
|
||||
GMime.Part? body_html = null;
|
||||
if (email.body_html != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue