[evolution/gnome-3-22] Some text could be skipped when converting the HTML to plain text



commit 9abee047d1406bfd6cd6d3686f252572bd81bcf8
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Sep 23 13:22:11 2016 +0200

    Some text could be skipped when converting the HTML to plain text
    
    The citation token could appear before the <br> one. Look for both of them and
    start from the one that is closer to the beginning.

 .../web-extension/e-editor-dom-functions.c         |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/modules/webkit-editor/web-extension/e-editor-dom-functions.c 
b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 7defc51..2373bce 100644
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -5127,6 +5127,7 @@ parse_html_into_blocks (EEditorPage *editor_page,
 {
        gboolean has_citation = FALSE, processing_last = FALSE;
        const gchar *prev_token, *next_token;
+       const gchar *next_br_token = NULL, *next_citation_token = NULL;
        GString *html = NULL;
        GRegex *regex_nbsp = NULL, *regex_link = NULL, *regex_email = NULL;
        WebKitDOMDocument *document;
@@ -5173,13 +5174,21 @@ parse_html_into_blocks (EEditorPage *editor_page,
        html = remove_new_lines_around_citations (input);
 
        prev_token = html->str;
-       next_token = strstr (prev_token + 1, "<br>");
+       next_br_token = (prev_token && *prev_token) ? strstr (prev_token + 1, "<br>") : NULL;
+       next_citation_token = (prev_token && *prev_token) ? strstr (prev_token + 1, "##CITATION_") : NULL;
+       if (next_br_token) {
+               if (next_citation_token)
+                       next_token = next_br_token < next_citation_token ? next_br_token : 
next_citation_token;
+               else
+                       next_token = next_br_token;
+       } else {
+               next_token = next_citation_token;
+       }
        processing_last = !next_token;
 
        while (next_token || processing_last) {
                const gchar *citation_start = NULL, *citation_end = NULL;
                const gchar *rest = NULL, *with_br = NULL;
-               const gchar *next_br_token = NULL, *next_citation_token = NULL;
                gchar *to_process = NULL, *to_insert = NULL;
                guint to_insert_start = 0, to_insert_end = 0;
 


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