[geary] Fix lost line breaks when selective quoting plain text. Bug 781178.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Fix lost line breaks when selective quoting plain text. Bug 781178.
- Date: Thu, 16 Nov 2017 07:11:08 +0000 (UTC)
commit c2afe8fe48c49965257ea5b859c0b2830280f78f
Author: Michael James Gratton <mike vee net>
Date: Thu Nov 16 18:01:43 2017 +1100
Fix lost line breaks when selective quoting plain text. Bug 781178.
* src/engine/rfc822/rfc822-utils.vala (quote_body): Smart escape quoted
part, preserving whitespace if source message is plain text. Throw
exceptions rather that catching them to clean the code paths up a
bit. Update call sites.
src/engine/rfc822/rfc822-utils.vala | 50 ++++++++++++++++++++--------------
1 files changed, 29 insertions(+), 21 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-utils.vala b/src/engine/rfc822/rfc822-utils.vala
index 49b3261..8611e64 100644
--- a/src/engine/rfc822/rfc822-utils.vala
+++ b/src/engine/rfc822/rfc822-utils.vala
@@ -257,7 +257,11 @@ public string quote_email_for_reply(Geary.Email email, string? quote, TextFormat
}
quoted += "<br />";
- quoted += quote_body(email, quote, true, format);
+ try {
+ quoted += quote_body(email, quote, true, format);
+ } catch (Error err) {
+ debug("Failed to quote body for replying: %s".printf(err.message));
+ }
return quoted;
}
@@ -290,31 +294,35 @@ public string quote_email_for_forward(Geary.Email email, string? quote, TextForm
quoted += _("Cc: %s\n").printf(cc_line);
quoted += "\n"; // A blank line between headers and body
quoted = quoted.replace("\n", "<br />");
- quoted += quote_body(email, quote, false, format);
+ try {
+ quoted += quote_body(email, quote, false, format);
+ } catch (Error err) {
+ debug("Failed to quote body for forwarding: %s".printf(err.message));
+ }
return quoted;
}
-private string quote_body(Geary.Email email, string? quote, bool use_quotes, TextFormat format) {
- string? body_text = quote ?? "";
+private string quote_body(Geary.Email email, string? quote, bool use_quotes, TextFormat format)
+ throws Error {
+ Message? message = email.get_message();
+ bool preserve_whitespace = !message.has_html_body();
+ string? body_text = null;
if (quote == null) {
- try {
- Message message = email.get_message();
- switch (format) {
- case TextFormat.HTML:
- body_text = message.has_html_body()
- ? message.get_html_body(null)
- : message.get_plain_body(true, null);
- break;
-
- case TextFormat.PLAIN:
- body_text = message.has_plain_body()
- ? message.get_plain_body(true, null)
- : message.get_html_body(null);
- break;
- }
- } catch (Error error) {
- debug("Could not get message text for quoting: %s", error.message);
+ switch (format) {
+ case TextFormat.HTML:
+ body_text = message.has_html_body()
+ ? message.get_html_body(null)
+ : message.get_plain_body(true, null);
+ break;
+
+ case TextFormat.PLAIN:
+ body_text = message.has_plain_body()
+ ? message.get_plain_body(true, null)
+ : message.get_html_body(null);
+ break;
}
+ } else {
+ body_text = Geary.HTML.smart_escape(quote, preserve_whitespace);
}
// Wrap the whole thing in a blockquote.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]