[evolution] Message credits are put on the end of quoted content instead of on its beginning.
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Message credits are put on the end of quoted content instead of on its beginning.
- Date: Mon, 2 Feb 2015 09:57:46 +0000 (UTC)
commit b4013262bea4bf82dcfe7f335dd710f80ca9b77e
Author: Tomas Popela <tpopela redhat com>
Date: Mon Feb 2 10:40:52 2015 +0100
Message credits are put on the end of quoted content instead of on its beginning.
I received one message and on its end there was the paragraph element
left opened:
</p><p></body></html>
When we appended the credentials after it:
</p><p></body></html><span class="-x-evo-to-body" data-credits><pre>credits</pre></span>
Now WebKit tried to do its best to parse, fix and load the content correctly that
resulted in:
<p><span class="-x-evo-to-body" data-credits></span></p><pre>credits</pre></body></html>
Clearly, we will fail when moving the credits to right place as we are
expecting the the credits are inner part of the span. So set the
credentials into the data-credits attribute (as there it will be
resistant against this behavior) and rework the part that's handling it.
e-util/e-html-editor-view.c | 44 +++++++++++++++++++++--------------
em-format/e-mail-formatter-quote.c | 2 +-
2 files changed, 27 insertions(+), 19 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 3651a39..0da22eb 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -1050,17 +1050,21 @@ move_elements_to_body (WebKitDOMDocument *document)
list = webkit_dom_document_query_selector_all (
document, "span.-x-evo-to-body[data-credits]", NULL);
for (ii = webkit_dom_node_list_get_length (list) - 1; ii >= 0; ii--) {
- WebKitDOMNode *child;
+ char *credits;
+ WebKitDOMElement *pre_element;
WebKitDOMNode *node = webkit_dom_node_list_item (list, ii);
- while ((child = webkit_dom_node_get_first_child (node))) {
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- child,
- webkit_dom_node_get_first_child (
- WEBKIT_DOM_NODE (body)),
- NULL);
- }
+ pre_element = webkit_dom_document_create_element (document, "pre", NULL);
+ credits = webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (node), "data-credits");
+ webkit_dom_html_element_set_inner_text (WEBKIT_DOM_HTML_ELEMENT (pre_element), credits, NULL);
+ g_free (credits);
+
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (pre_element),
+ webkit_dom_node_get_first_child (
+ WEBKIT_DOM_NODE (body)),
+ NULL);
remove_node (node);
}
@@ -4904,16 +4908,20 @@ html_editor_convert_view_content (EHTMLEditorView *view,
document, "span.-x-evo-to-body[data-credits]", NULL);
length = webkit_dom_node_list_get_length (list);
for (ii = 0; ii < length; ii++) {
- WebKitDOMNode *node, *child;
+ char *credits;
+ WebKitDOMElement *pre_element;
+ WebKitDOMNode *node = webkit_dom_node_list_item (list, ii);
- node = webkit_dom_node_list_item (list, ii);
- while ((child = webkit_dom_node_get_first_child (node))) {
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (wrapper),
- child,
- WEBKIT_DOM_NODE (content_wrapper),
- NULL);
- }
+ pre_element = webkit_dom_document_create_element (document, "pre", NULL);
+ credits = webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (node), "data-credits");
+ webkit_dom_html_element_set_inner_text (WEBKIT_DOM_HTML_ELEMENT (pre_element), credits, NULL);
+ g_free (credits);
+
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (wrapper),
+ WEBKIT_DOM_NODE (pre_element),
+ WEBKIT_DOM_NODE (content_wrapper),
+ NULL);
remove_node (node);
}
diff --git a/em-format/e-mail-formatter-quote.c b/em-format/e-mail-formatter-quote.c
index bbd2da4..1916bba 100644
--- a/em-format/e-mail-formatter-quote.c
+++ b/em-format/e-mail-formatter-quote.c
@@ -122,7 +122,7 @@ mail_formatter_quote_run (EMailFormatter *formatter,
* the special span element and it will be moved to body in EHTMLEditorView */
if (qf->priv->credits && *qf->priv->credits) {
gchar *credits = g_strdup_printf (
- "<span class=\"-x-evo-to-body\" data-credits><pre>%s</pre></span>",
+ "<span class=\"-x-evo-to-body\" data-credits=\"%s\"></span>",
qf->priv->credits);
g_output_stream_write_all (
stream, credits, strlen (credits), NULL, cancellable, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]