|
|
b57bd2 |
diff -up evolution-3.28.5/src/e-util/test-html-editor-units-bugs.c.composer-mangled-quotation evolution-3.28.5/src/e-util/test-html-editor-units-bugs.c
|
|
|
b57bd2 |
--- evolution-3.28.5/src/e-util/test-html-editor-units-bugs.c.composer-mangled-quotation 2018-07-30 15:37:05.000000000 +0200
|
|
|
b57bd2 |
+++ evolution-3.28.5/src/e-util/test-html-editor-units-bugs.c 2018-11-09 13:27:45.699170089 +0100
|
|
|
b57bd2 |
@@ -1205,6 +1205,120 @@ test_bug_750636 (TestFixture *fixture)
|
|
|
b57bd2 |
g_test_fail ();
|
|
|
b57bd2 |
}
|
|
|
b57bd2 |
|
|
|
b57bd2 |
+static void
|
|
|
b57bd2 |
+test_issue_86 (TestFixture *fixture)
|
|
|
b57bd2 |
+{
|
|
|
b57bd2 |
+ const gchar *source_text =
|
|
|
b57bd2 |
+ "normal text\n"
|
|
|
b57bd2 |
+ "\n"
|
|
|
b57bd2 |
+ "> level 1\n"
|
|
|
b57bd2 |
+ "> level 1\n"
|
|
|
b57bd2 |
+ "> > level 2\n"
|
|
|
b57bd2 |
+ "> > level 2\n"
|
|
|
b57bd2 |
+ "> >\n"
|
|
|
b57bd2 |
+ "> > level 2\n"
|
|
|
b57bd2 |
+ ">\n"
|
|
|
b57bd2 |
+ "> level 1\n"
|
|
|
b57bd2 |
+ "> level 1\n"
|
|
|
b57bd2 |
+ ">\n"
|
|
|
b57bd2 |
+ "> > > level 3\n"
|
|
|
b57bd2 |
+ "> > > level 3\n"
|
|
|
b57bd2 |
+ ">\n"
|
|
|
b57bd2 |
+ "> > level 2\n"
|
|
|
b57bd2 |
+ "> > level 2\n"
|
|
|
b57bd2 |
+ ">\n"
|
|
|
b57bd2 |
+ "> level 1\n"
|
|
|
b57bd2 |
+ "\n"
|
|
|
b57bd2 |
+ "back normal text\n";
|
|
|
b57bd2 |
+ gchar *converted, *to_insert;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ if (!test_utils_process_commands (fixture,
|
|
|
b57bd2 |
+ "mode:html\n")) {
|
|
|
b57bd2 |
+ g_test_fail ();
|
|
|
b57bd2 |
+ return;
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ converted = camel_text_to_html (source_text,
|
|
|
b57bd2 |
+ CAMEL_MIME_FILTER_TOHTML_PRE |
|
|
|
b57bd2 |
+ CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
|
|
|
b57bd2 |
+ CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES |
|
|
|
b57bd2 |
+ CAMEL_MIME_FILTER_TOHTML_QUOTE_CITATION,
|
|
|
b57bd2 |
+ 0xDDDDDD);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ g_return_if_fail (converted != NULL);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ to_insert = g_strconcat (converted,
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "",
|
|
|
b57bd2 |
+ NULL);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ test_utils_insert_content (fixture, to_insert,
|
|
|
b57bd2 |
+ E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ if (!test_utils_run_simple_test (fixture,
|
|
|
b57bd2 |
+ "",
|
|
|
b57bd2 |
+ HTML_PREFIX "On Today, User wrote: "
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "normal text "
|
|
|
b57bd2 |
+ "
"
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "level 1 "
|
|
|
b57bd2 |
+ "level 1 "
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "level 2 "
|
|
|
b57bd2 |
+ "level 2 "
|
|
|
b57bd2 |
+ "
"
|
|
|
b57bd2 |
+ "level 2 "
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "
"
|
|
|
b57bd2 |
+ "level 1 "
|
|
|
b57bd2 |
+ "level 1 "
|
|
|
b57bd2 |
+ "
"
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "level 3 "
|
|
|
b57bd2 |
+ "level 3 "
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "
"
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "level 2 "
|
|
|
b57bd2 |
+ "level 2 "
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "
"
|
|
|
b57bd2 |
+ "level 1 "
|
|
|
b57bd2 |
+ ""
|
|
|
b57bd2 |
+ "
"
|
|
|
b57bd2 |
+ "back normal text "
|
|
|
b57bd2 |
+ "" HTML_SUFFIX,
|
|
|
b57bd2 |
+ "On Today, User wrote:\n"
|
|
|
b57bd2 |
+ "> normal text\n"
|
|
|
b57bd2 |
+ "> \n"
|
|
|
b57bd2 |
+ "> > level 1\n"
|
|
|
b57bd2 |
+ "> > level 1\n"
|
|
|
b57bd2 |
+ "> > > level 2\n"
|
|
|
b57bd2 |
+ "> > > level 2\n"
|
|
|
b57bd2 |
+ "> > > \n"
|
|
|
b57bd2 |
+ "> > > level 2\n"
|
|
|
b57bd2 |
+ "> > \n"
|
|
|
b57bd2 |
+ "> > level 1\n"
|
|
|
b57bd2 |
+ "> > level 1\n"
|
|
|
b57bd2 |
+ "> > \n"
|
|
|
b57bd2 |
+ "> > > > level 3\n"
|
|
|
b57bd2 |
+ "> > > > level 3\n"
|
|
|
b57bd2 |
+ "> > \n"
|
|
|
b57bd2 |
+ "> > > level 2\n"
|
|
|
b57bd2 |
+ "> > > level 2\n"
|
|
|
b57bd2 |
+ "> > \n"
|
|
|
b57bd2 |
+ "> > level 1\n"
|
|
|
b57bd2 |
+ "> \n"
|
|
|
b57bd2 |
+ "> back normal text"))
|
|
|
b57bd2 |
+ g_test_fail ();
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ g_free (to_insert);
|
|
|
b57bd2 |
+ g_free (converted);
|
|
|
b57bd2 |
+}
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
void
|
|
|
b57bd2 |
test_add_html_editor_bug_tests (void)
|
|
|
b57bd2 |
{
|
|
|
b57bd2 |
@@ -1234,4 +1348,5 @@ test_add_html_editor_bug_tests (void)
|
|
|
b57bd2 |
test_utils_add_test ("/bug/780088", test_bug_780088);
|
|
|
b57bd2 |
test_utils_add_test ("/bug/788829", test_bug_788829);
|
|
|
b57bd2 |
test_utils_add_test ("/bug/750636", test_bug_750636);
|
|
|
b57bd2 |
+ test_utils_add_test ("/issue/86", test_issue_86);
|
|
|
b57bd2 |
}
|
|
|
b57bd2 |
diff -up evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c.composer-mangled-quotation evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
|
|
|
b57bd2 |
--- evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c.composer-mangled-quotation 2018-07-30 15:37:05.000000000 +0200
|
|
|
b57bd2 |
+++ evolution-3.28.5/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c 2018-11-09 13:29:06.551168971 +0100
|
|
|
b57bd2 |
@@ -6230,7 +6230,6 @@ e_editor_dom_convert_content (EEditorPag
|
|
|
b57bd2 |
WEBKIT_DOM_NODE (content_wrapper),
|
|
|
b57bd2 |
WEBKIT_DOM_NODE (e_editor_dom_prepare_paragraph (editor_page, FALSE)),
|
|
|
b57bd2 |
NULL);
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
if (!cite_body) {
|
|
|
b57bd2 |
if (!empty) {
|
|
|
b57bd2 |
WebKitDOMNode *child;
|
|
|
b57bd2 |
@@ -8754,6 +8753,133 @@ adapt_to_editor_dom_changes (WebKitDOMDo
|
|
|
b57bd2 |
g_clear_object (&collection);
|
|
|
b57bd2 |
}
|
|
|
b57bd2 |
|
|
|
b57bd2 |
+static void
|
|
|
b57bd2 |
+traverse_nodes_to_split_pre (WebKitDOMDocument *document,
|
|
|
b57bd2 |
+ WebKitDOMNode *node,
|
|
|
b57bd2 |
+ WebKitDOMNode *new_parent, /* can be NULL, then prepend to out_new_nodes */
|
|
|
b57bd2 |
+ gboolean is_in_pre,
|
|
|
b57bd2 |
+ GSList **out_new_nodes) /* WebKitDOMNode * */
|
|
|
b57bd2 |
+{
|
|
|
b57bd2 |
+ if (is_in_pre && WEBKIT_DOM_IS_TEXT (node)) {
|
|
|
b57bd2 |
+ gchar *text;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ text = webkit_dom_text_get_whole_text (WEBKIT_DOM_TEXT (node));
|
|
|
b57bd2 |
+ if (text) {
|
|
|
b57bd2 |
+ WebKitDOMElement *pre;
|
|
|
b57bd2 |
+ gint ii;
|
|
|
b57bd2 |
+ gchar **strv;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ strv = g_strsplit (text, "\n", -1);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ for (ii = 0; strv && strv[ii]; ii++) {
|
|
|
b57bd2 |
+ if (*(strv[ii])) {
|
|
|
b57bd2 |
+ gint len = strlen (strv[ii]);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ if (strv[ii][len - 1] == '\r') {
|
|
|
b57bd2 |
+ strv[ii][len - 1] = '\0';
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ /* is shown as a block, thus adding a new line at the end behaves like two -s */
|
|
|
b57bd2 |
+ if (!*(strv[ii]) && !strv[ii + 1])
|
|
|
b57bd2 |
+ break;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ pre = webkit_dom_document_create_element (document, "pre", NULL);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ if (*(strv[ii])) {
|
|
|
b57bd2 |
+ webkit_dom_html_element_set_inner_text (WEBKIT_DOM_HTML_ELEMENT (pre), strv[ii], NULL);
|
|
|
b57bd2 |
+ } else {
|
|
|
b57bd2 |
+ WebKitDOMElement *br;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ br = webkit_dom_document_create_element (document, "br", NULL);
|
|
|
b57bd2 |
+ webkit_dom_node_append_child (WEBKIT_DOM_NODE (pre), WEBKIT_DOM_NODE (br), NULL);
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ if (new_parent)
|
|
|
b57bd2 |
+ webkit_dom_node_append_child (new_parent, WEBKIT_DOM_NODE (pre), NULL);
|
|
|
b57bd2 |
+ else
|
|
|
b57bd2 |
+ *out_new_nodes = g_slist_prepend (*out_new_nodes, pre);
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ g_strfreev (strv);
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ g_free (text);
|
|
|
b57bd2 |
+ } else if (WEBKIT_DOM_IS_HTML_PRE_ELEMENT (node)) {
|
|
|
b57bd2 |
+ is_in_pre = TRUE;
|
|
|
b57bd2 |
+ } else {
|
|
|
b57bd2 |
+ WebKitDOMNode *nd;
|
|
|
b57bd2 |
+ GError *error = NULL;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ nd = webkit_dom_node_clone_node_with_error (node, FALSE, &error);
|
|
|
b57bd2 |
+ if (nd) {
|
|
|
b57bd2 |
+ if (new_parent)
|
|
|
b57bd2 |
+ webkit_dom_node_append_child (new_parent, nd, NULL);
|
|
|
b57bd2 |
+ else
|
|
|
b57bd2 |
+ *out_new_nodes = g_slist_prepend (*out_new_nodes, nd);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ new_parent = nd;
|
|
|
b57bd2 |
+ } else {
|
|
|
b57bd2 |
+ g_warning ("%s: Failed to clone node %s: %s\n", G_STRFUNC, G_OBJECT_TYPE_NAME (node), error ? error->message : "Unknown error");
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ for (node = webkit_dom_node_get_first_child (node);
|
|
|
b57bd2 |
+ node;
|
|
|
b57bd2 |
+ node = webkit_dom_node_get_next_sibling (node)) {
|
|
|
b57bd2 |
+ traverse_nodes_to_split_pre (document, node, new_parent, is_in_pre, out_new_nodes);
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+}
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+static void
|
|
|
b57bd2 |
+maybe_split_pre_paragraphs (WebKitDOMDocument *document)
|
|
|
b57bd2 |
+{
|
|
|
b57bd2 |
+ WebKitDOMHTMLElement *body;
|
|
|
b57bd2 |
+ WebKitDOMNodeList *list;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ body = webkit_dom_document_get_body (document);
|
|
|
b57bd2 |
+ if (!body)
|
|
|
b57bd2 |
+ return;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ list = webkit_dom_document_query_selector_all (document, "pre", NULL);
|
|
|
b57bd2 |
+ if (webkit_dom_node_list_get_length (list)) {
|
|
|
b57bd2 |
+ WebKitDOMNode *body_node, *node, *current;
|
|
|
b57bd2 |
+ GSList *new_nodes = NULL, *to_remove = NULL, *link;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ g_clear_object (&list);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ body_node = WEBKIT_DOM_NODE (body);
|
|
|
b57bd2 |
+ webkit_dom_node_normalize (body_node);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ for (current = webkit_dom_node_get_first_child (body_node);
|
|
|
b57bd2 |
+ current;
|
|
|
b57bd2 |
+ current = webkit_dom_node_get_next_sibling (current)) {
|
|
|
b57bd2 |
+ traverse_nodes_to_split_pre (document, current, NULL, FALSE, &new_nodes);
|
|
|
b57bd2 |
+ to_remove = g_slist_prepend (to_remove, current);
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ for (link = to_remove; link; link = g_slist_next (link)) {
|
|
|
b57bd2 |
+ node = link->data;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ webkit_dom_node_remove_child (body_node, node, NULL);
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ /* They are in reverse order, thus reverse it */
|
|
|
b57bd2 |
+ new_nodes = g_slist_reverse (new_nodes);
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ for (link = new_nodes; link; link = g_slist_next (link)) {
|
|
|
b57bd2 |
+ node = link->data;
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ webkit_dom_node_append_child (body_node, node, NULL);
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ g_slist_free (to_remove);
|
|
|
b57bd2 |
+ g_slist_free (new_nodes);
|
|
|
b57bd2 |
+ }
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
+ g_clear_object (&list);
|
|
|
b57bd2 |
+}
|
|
|
b57bd2 |
+
|
|
|
b57bd2 |
void
|
|
|
b57bd2 |
e_editor_dom_process_content_after_load (EEditorPage *editor_page)
|
|
|
b57bd2 |
{
|
|
|
b57bd2 |
@@ -8803,60 +8929,8 @@ e_editor_dom_process_content_after_load
|
|
|
b57bd2 |
}
|
|
|
b57bd2 |
|
|
|
b57bd2 |
goto out;
|
|
|
b57bd2 |
- } else {
|
|
|
b57bd2 |
- WebKitDOMNodeList *list;
|
|
|
b57bd2 |
- gulong ii;
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- list = webkit_dom_document_query_selector_all (document, "pre", NULL);
|
|
|
b57bd2 |
- for (ii = webkit_dom_node_list_get_length (list); ii--;) {
|
|
|
b57bd2 |
- WebKitDOMNode *node = webkit_dom_node_list_item (list, ii), *parent;
|
|
|
b57bd2 |
- WebKitDOMElement *element;
|
|
|
b57bd2 |
- gchar *inner_html;
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- element = WEBKIT_DOM_ELEMENT (node);
|
|
|
b57bd2 |
- parent = webkit_dom_node_get_parent_node (node);
|
|
|
b57bd2 |
- inner_html = webkit_dom_element_get_inner_html (element);
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- if (inner_html && *inner_html) {
|
|
|
b57bd2 |
- gchar **strv;
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- strv = g_strsplit (inner_html, "\n", -1);
|
|
|
b57bd2 |
- if (strv && strv[0] && strv[1]) {
|
|
|
b57bd2 |
- WebKitDOMElement *pre;
|
|
|
b57bd2 |
- gint jj;
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- for (jj = 0; strv[jj]; jj++) {
|
|
|
b57bd2 |
- pre = webkit_dom_document_create_element (document, "pre", NULL);
|
|
|
b57bd2 |
- if (*(strv[jj])) {
|
|
|
b57bd2 |
- gint len = strlen (strv[jj]);
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- if (strv[jj][len - 1] == '\r') {
|
|
|
b57bd2 |
- strv[jj][len - 1] = '\0';
|
|
|
b57bd2 |
- }
|
|
|
b57bd2 |
- }
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- if (*(strv[jj])) {
|
|
|
b57bd2 |
- webkit_dom_html_element_set_inner_html (WEBKIT_DOM_HTML_ELEMENT (pre), strv[jj], NULL);
|
|
|
b57bd2 |
- } else {
|
|
|
b57bd2 |
- WebKitDOMElement *br;
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- br = webkit_dom_document_create_element (document, "br", NULL);
|
|
|
b57bd2 |
- webkit_dom_node_append_child (WEBKIT_DOM_NODE (pre), WEBKIT_DOM_NODE (br), NULL);
|
|
|
b57bd2 |
- }
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- webkit_dom_node_insert_before (parent, WEBKIT_DOM_NODE (pre), node, NULL);
|
|
|
b57bd2 |
- }
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- remove_node (node);
|
|
|
b57bd2 |
- }
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- g_strfreev (strv);
|
|
|
b57bd2 |
- }
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- g_free (inner_html);
|
|
|
b57bd2 |
- }
|
|
|
b57bd2 |
-
|
|
|
b57bd2 |
- g_clear_object (&list);
|
|
|
b57bd2 |
+ } else if (!webkit_dom_element_has_attribute (WEBKIT_DOM_ELEMENT (body), "data-evo-draft")) {
|
|
|
b57bd2 |
+ maybe_split_pre_paragraphs (document);
|
|
|
b57bd2 |
}
|
|
|
b57bd2 |
|
|
|
b57bd2 |
adapt_to_editor_dom_changes (document);
|