[Xfce4-commits] <postler:master> Split lines and quote more carefully

Christian Dywan noreply at xfce.org
Wed Dec 15 18:22:02 CET 2010


Updating branch refs/heads/master
         to dcb9c1a3fe77c910cd73c7236d57d9fee5366056 (commit)
       from ba6687bc03d53287ff9fdcfa4633a53626dc50b2 (commit)

commit dcb9c1a3fe77c910cd73c7236d57d9fee5366056
Author: Bernd Prünster <bernd.pruenster at gmail.com>
Date:   Wed Dec 15 18:17:48 2010 +0100

    Split lines and quote more carefully
    
    Fixes: https://bugs.launchpad.net/postler/+bug/671564

 postler/postler-content.vala |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index f68a1e5..0f2ebff 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -417,15 +417,25 @@ public class Postler.Content : WebKit.WebView {
                      || effective == "-----BEGIN PGP SIGNATURE-----")
                         continue;
                     last_line_empty = false;
-
-                    size_t length = line.length;
-                    /* TODO: Handle encoding */
-                    for (int i = 0; i < length; i += (quote ? 78 : 80))
-                        body.append ((quote ? "> " : "")
-                            + line.substring (i, (long)(length - i)) + "\n");
+                    string[] words_in_line = line.split (" ");
+                    long len = 0;
+                    body.append ((quote ? "> " : ""));
+                    for (int i = 0; i < words_in_line.length; i++)
+                    {
+                        len += words_in_line[i].length + 1;
+                        if (len < (quote ? 70 : 72)) {
+                            body.append (words_in_line[i]);
+                            body.append_c (' ');
+                        } else {
+                            body.append_c ('\n');
+                            body.append ((quote ? "> " : ""));
+                            body.append (words_in_line[i]);
+                            body.append_c (' ');
+                            len = 0;
+                        }
+                    }
+                    body.append ("\n");
                 }
-                if (!last_line_empty)
-                    body.append_c ('\n');
             } catch (GLib.Error error) {
                 display_error (_("Failed to quote message \"%s\": %s").printf (
                     contents.get_path (), error.message));



More information about the Xfce4-commits mailing list