[evolution/gnome-3-30] I#107 - Reply with selection and URL can produce extra letters ][



commit 5cd27023f5b86ad2e8b91fc1be2f99e0a37dfdf0
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 12 12:11:32 2018 +0200

    I#107 - Reply with selection and URL can produce extra letters ][
    
    Extend the change for tabs, which are replaced with <span> and as such
    can be considered part of the URL, which breaks the URL lookup.
    
    Related to https://gitlab.gnome.org/GNOME/evolution/issues/107

 src/e-util/test-html-editor-units-bugs.c           |  8 ++++--
 .../web-extension/e-editor-dom-functions.c         | 32 +++++++++++++---------
 2 files changed, 25 insertions(+), 15 deletions(-)
---
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index ae4a9e925f..ae6901e20b 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -1432,7 +1432,9 @@ test_issue_107 (TestFixture *fixture)
                "&lt;<a href=\"https://www.10.org/\";>https://www.10.org/</a>&#160;?&gt;\n"
                "&#160;<a href=\"https://www.11.org/\";>https://www.11.org/</a>&#160;\n"
                "&lt;&#160;<a href=\"https://www.12.org/\";>https://www.12.org/</a>&#160;&gt;\n"
-               "&#160;&lt;<a href=\"https://www.13.org/\";>https://www.13.org/</a>&gt;&#160;\n</pre>"
+               "&#160;&lt;<a href=\"https://www.13.org/\";>https://www.13.org/</a>&gt;&#160;\n"
+               "Text https://www.14.org/\temail: user@no.where\n"
+               "</pre>"
                "<span class=\"-x-evo-to-body\" data-credits=\"On Today, User wrote:\"></span>"
                "<span class=\"-x-evo-cite-body\"></span>",
                E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
@@ -1456,6 +1458,7 @@ test_issue_107 (TestFixture *fixture)
                "<div style=\"width: 71ch;\">&gt; &nbsp;<a 
href=\"https://www.11.org/\";>https://www.11.org/</a>&nbsp;</div>"
                "<div style=\"width: 71ch;\">&gt; &lt;&nbsp;<a 
href=\"https://www.12.org/\";>https://www.12.org/</a>&nbsp;&gt;</div>"
                "<div style=\"width: 71ch;\">&gt; &nbsp;&lt;<a 
href=\"https://www.13.org/\";>https://www.13.org/</a>&gt;&nbsp;</div>"
+               "<div style=\"width: 71ch;\">&gt; Text <a 
href=\"https://www.14.org/\";>https://www.14.org/</a>\temail: user@no.where</div>"
                "</blockquote>" HTML_SUFFIX,
                "On Today, User wrote:\n"
                "> text\n"
@@ -1471,7 +1474,8 @@ test_issue_107 (TestFixture *fixture)
                "> <https://www.10.org/ ?>\n"
                ">  https://www.11.org/ \n"
                "> < https://www.12.org/ >\n"
-               ">  <https://www.13.org/> ")) {
+               ">  <https://www.13.org/> \n"
+               "> Text https://www.14.org/\temail: user@no.where")) {
                g_test_fail ();
        }
 }
diff --git a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c 
b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index cf42e7a25c..540477cf4b 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -5359,25 +5359,18 @@ parse_html_into_blocks (EEditorPage *editor_page,
                }
 
                if ((to_insert = g_utf8_substring (to_process, to_insert_start, to_insert_end)) && 
*to_insert) {
-                       gboolean empty = FALSE;
                        gchar *truncated = g_strdup (to_insert);
                        gchar *rest_to_insert;
 
                        if (camel_debug ("webkit:editor"))
                                printf ("\tto_insert: '%s'\n", to_insert);
 
-                       empty = !*truncated && strlen (to_insert) > 0;
-
-                       rest_to_insert = g_regex_replace_eval (
-                               regex_nbsp,
-                               empty ? rest : truncated,
-                               -1,
-                               0,
-                               0,
-                               (GRegexEvalCallback) replace_to_nbsp,
-                               NULL,
-                               NULL);
-                       g_free (truncated);
+                       if (!*truncated && strlen (to_insert) > 0) {
+                               rest_to_insert = g_strdup (rest);
+                               g_free (truncated);
+                       } else {
+                               rest_to_insert = truncated;
+                       }
 
                        replace_selection_markers (&rest_to_insert);
 
@@ -5405,6 +5398,19 @@ parse_html_into_blocks (EEditorPage *editor_page,
                                rest_to_insert = truncated;
                        }
 
+                       /* Do it after the anchor change */
+                       truncated = g_regex_replace_eval (
+                               regex_nbsp,
+                               rest_to_insert,
+                               -1,
+                               0,
+                               0,
+                               (GRegexEvalCallback) replace_to_nbsp,
+                               NULL,
+                               NULL);
+                       g_free (rest_to_insert);
+                       rest_to_insert = truncated;
+
                        create_and_append_new_block (
                                editor_page, parent, block_template, rest_to_insert);
 


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