[evolution] Bug 752997 - Crash when replying to the message



commit 720e17489e35c73ad2325f8d513c51e1044a3979
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Jul 31 10:34:22 2015 +0200

    Bug 752997 - Crash when replying to the message
    
    The problem is that WebKit1 (2.4.9) crashes when it is trying to move or remove
    an anchor element that has an image element inside and this image element has
    the CSS float property set in the style attribute. To workaround it we will rename
    the style attribute and rename it back when we will send the message. It is
    unfortunate that we can change the formatting with this, but this is definitely
    better than crashing. This could be removed once Evolution switches to WebKit2
    as the WebKit2 is unaffected (tested on 2.8.4).

 e-util/e-html-editor-view.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index e09ff41..392f2e5 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -9384,6 +9384,19 @@ process_content_for_html (EHTMLEditorView *view)
        }
        g_object_unref (list);
 
+       list = webkit_dom_element_query_selector_all (
+               WEBKIT_DOM_ELEMENT (node), "[data-style]", NULL);
+       length = webkit_dom_node_list_get_length (list);
+       for (ii = 0; ii < length; ii++) {
+               WebKitDOMNode *data_style_node;
+
+               data_style_node = webkit_dom_node_list_item (list, ii);
+
+               rename_attribute (WEBKIT_DOM_ELEMENT (data_style_node), "data-style", "style");
+               g_object_unref (data_style_node);
+       }
+       g_object_unref (list);
+
        process_elements (view, node, FALSE, FALSE, NULL);
 
        html_content = webkit_dom_html_element_get_outer_html (
@@ -9683,9 +9696,11 @@ style_updated_cb (EHTMLEditorView *view)
 static void
 html_editor_view_load_status_changed (EHTMLEditorView *view)
 {
+       glong ii, length;
        WebKitDOMDocument *document;
        WebKitDOMDOMWindow *dom_window;
        WebKitDOMHTMLElement *body;
+       WebKitDOMNodeList *list;
        WebKitLoadStatus status;
 
        status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW (view));
@@ -9727,6 +9742,31 @@ html_editor_view_load_status_changed (EHTMLEditorView *view)
        webkit_dom_element_set_attribute (
                WEBKIT_DOM_ELEMENT (body), "data-message", "", NULL);
 
+       /* Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=752997 where
+       * WebKit (2.4.9) crashes when it is trying to move or remove an anchor
+       * element that has an image element inside and this image element has
+       * the CSS float property set in the style attribute. To workaround it we
+       * will rename the style attribute and rename it back when we will send
+       * the message. It is unfortunate that we can change the formatting with
+       * this, but this is definitely better than crashing. This could be
+       * removed once Evolution switches to WebKit2 as the WebKit2 is unaffected
+       * (tested on 2.8.4). */
+       list = webkit_dom_document_query_selector_all (document, "a img[style]", NULL);
+       length = webkit_dom_node_list_get_length (list);
+       for (ii = 0; ii < length; ii++) {
+               WebKitDOMNode *node;
+               gchar *style_value;
+
+               node = webkit_dom_node_list_item (list, ii);
+               style_value = webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (node), "style");
+               if (camel_strstrcase (style_value, "float"))
+                       rename_attribute (WEBKIT_DOM_ELEMENT (node), "style", "data-style");
+               g_free (style_value);
+
+               g_object_unref (node);
+       }
+       g_object_unref (list);
+
        if (view->priv->convert_in_situ) {
                html_editor_convert_view_content (view, NULL);
                /* Make the quote marks non-selectable. */


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