[geary] Fix infinite loop when sending long space-stuffed line. Bug 768642.



commit 6aacb75e387ee4783eb2b3a012e59a3b2647fc17
Author: Michael James Gratton <mike vee net>
Date:   Sat Jul 30 13:23:51 2016 +1000

    Fix infinite loop when sending long space-stuffed line. Bug 768642.
    
    * src/client/util/util-webkit.vala (Util.DOM.html_to_flowed_text): If a
      line is space-stuffed, ignore the stuffing space when determining where
      to break the line.

 src/client/util/util-webkit.vala |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/client/util/util-webkit.vala b/src/client/util/util-webkit.vala
index b542449..beb3b02 100644
--- a/src/client/util/util-webkit.vala
+++ b/src/client/util/util-webkit.vala
@@ -303,7 +303,11 @@ namespace Util.DOM {
         return outtext;
     }
 
-    // This will modify/reset the DOM
+    /**
+     * Convert a HTML DOM tree to RFC 3676 format=flowed text.
+     *
+     * This will modify/reset the DOM.
+     */
     public string html_to_flowed_text(WebKit.DOM.HTMLElement el) {
         string saved_doc = el.get_inner_html();
         WebKit.DOM.NodeList blockquotes;
@@ -362,15 +366,19 @@ namespace Util.DOM {
             int max_len = 72 - prefix.length;
 
             do {
-                if (quote_level == 0 && (line.has_prefix(">") || line.has_prefix("From")))
+                int start_ind = 0;
+                if (quote_level == 0 &&
+                    (line.has_prefix(">") || line.has_prefix("From"))) {
                     line = " " + line;
+                    start_ind = 1;
+                }
 
                 int cut_ind = line.length;
                 if (cut_ind > max_len) {
                     string beg = line[0:max_len];
-                    cut_ind = beg.last_index_of(" ") + 1;
+                    cut_ind = beg.last_index_of(" ", start_ind) + 1;
                     if (cut_ind == 0) {
-                        cut_ind = line.index_of(" ") + 1;
+                        cut_ind = line.index_of(" ", start_ind) + 1;
                         if (cut_ind == 0)
                             cut_ind = line.length;
                         if (cut_ind > 998 - prefix.length)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]