[evolution/gnome-3-16] EHTMLEditorView - Appending text to the link is broken
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-16] EHTMLEditorView - Appending text to the link is broken
- Date: Wed, 10 Jun 2015 08:14:16 +0000 (UTC)
commit 36893d550bb0f68b4ab36db6f381b2c640fdfc3b
Author: Tomas Popela <tpopela redhat com>
Date: Wed Jun 10 08:58:09 2015 +0200
EHTMLEditorView - Appending text to the link is broken
Writing "www.gnome.org" followed by space into comopser, then moving the caret
one character left and typing "a" would append the "a " to the link.
Also don't leak the text that we are going to append.
e-util/e-html-editor-view.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 8e57fe5..4f73f64 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -1603,12 +1603,11 @@ html_editor_view_check_magic_links (EHTMLEditorView *view,
g_free (url_end_raw);
g_free (final_url);
} else {
+ gboolean appending_to_link = FALSE;
+ gchar *href, *text, *url, *text_to_append = NULL;
+ gint diff;
WebKitDOMElement *parent;
WebKitDOMNode *prev_sibling;
- gchar *href, *text, *url;
- gint diff;
- const char* text_to_append;
- gboolean appending_to_link = FALSE;
parent = webkit_dom_node_get_parent_element (node);
prev_sibling = webkit_dom_node_get_previous_sibling (node);
@@ -1617,19 +1616,31 @@ html_editor_view_check_magic_links (EHTMLEditorView *view,
* space => we're appending to link */
if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (prev_sibling)) {
text_to_append = webkit_dom_node_get_text_content (node);
- if (g_strcmp0 (text_to_append, "") != 0 &&
- !g_unichar_isspace (g_utf8_get_char (text_to_append))) {
+ if (text_to_append && *text_to_append &&
+ !g_unichar_isspace (g_utf8_get_char (text_to_append))) {
appending_to_link = TRUE;
parent = WEBKIT_DOM_ELEMENT (prev_sibling);
+ /* If the node(text) contains the some of unwanted characters
+ * split it into two nodes and select the right one. */
+ if (g_str_has_suffix (text_to_append, UNICODE_NBSP) ||
+ g_str_has_suffix (text_to_append, UNICODE_ZERO_WIDTH_SPACE)) {
+ webkit_dom_text_split_text (
+ WEBKIT_DOM_TEXT (node),
+ g_utf8_strlen (text_to_append, -1) - 1,
+ NULL);
+ g_free (text_to_append);
+ text_to_append = webkit_dom_node_get_text_content (node);
+ }
}
}
/* If parent is ANCHOR => we're editing the link */
- if (!WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (parent) && !appending_to_link) {
+ if ((!WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (parent) && !appending_to_link) || !text_to_append) {
g_match_info_free (match_info);
g_regex_unref (regex);
g_free (node_text);
+ g_free (text_to_append);
return;
}
@@ -1721,6 +1732,7 @@ html_editor_view_check_magic_links (EHTMLEditorView *view,
}
}
+ g_free (text_to_append);
g_free (text);
g_free (href);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]