[evolution] Bug 733877 - Parse attachments on demand, not on message open ]I[
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 733877 - Parse attachments on demand, not on message open ]I[
- Date: Wed, 19 Aug 2015 14:09:58 +0000 (UTC)
commit 74a97a1a38d22ffd85a3f579468136c474be0adf
Author: Milan Crha <mcrha redhat com>
Date: Wed Aug 19 16:07:44 2015 +0200
Bug 733877 - Parse attachments on demand, not on message open ]I[
Fixes possible crash when viewing mailing list message digest.
em-format/e-mail-formatter-attachment.c | 27 +++++++++++++-----
em-format/e-mail-part.c | 45 +++++++++++++++++++++++++++++++
em-format/e-mail-part.h | 1 +
mail/e-mail-display.c | 22 ++-------------
4 files changed, 69 insertions(+), 26 deletions(-)
---
diff --git a/em-format/e-mail-formatter-attachment.c b/em-format/e-mail-formatter-attachment.c
index dc60514..f23c37d 100644
--- a/em-format/e-mail-formatter-attachment.c
+++ b/em-format/e-mail-formatter-attachment.c
@@ -323,7 +323,7 @@ emfe_attachment_format (EMailFormatterExtension *extension,
}
if (success) {
- gchar *wrapper_element_id, *inner_html_data;
+ gchar *wrapper_element_id;
gconstpointer data;
gsize size;
@@ -335,20 +335,33 @@ emfe_attachment_format (EMailFormatterExtension *extension,
size = g_memory_output_stream_get_data_size (
G_MEMORY_OUTPUT_STREAM (content_stream));
- inner_html_data = g_markup_escape_text (data, size);
-
g_string_append_printf (
buffer,
"<tr><td colspan=\"2\">"
- "<div class=\"attachment-wrapper\" id=\"%s\" inner-html-data=\"%s\">",
- wrapper_element_id, inner_html_data);
+ "<div class=\"attachment-wrapper\" id=\"%s\"",
+ wrapper_element_id);
+
+ if (e_mail_part_should_show_inline (part)) {
+ g_string_append (buffer, ">");
+ g_string_append_len (buffer, data, size);
+ } else {
+ gchar *inner_html_data;
+
+ inner_html_data = g_markup_escape_text (data, size);
+
+ g_string_append_printf (
+ buffer,
+ " inner-html-data=\"%s\">",
+ inner_html_data);
+
+ g_free (inner_html_data);
+ }
g_string_append (buffer, "</div></td></tr>");
- e_mail_part_attachment_set_expandable (E_MAIL_PART_ATTACHMENT (part), TRUE);
+ e_mail_part_attachment_set_expandable (empa, TRUE);
g_free (wrapper_element_id);
- g_free (inner_html_data);
}
g_object_unref (content_stream);
diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c
index 8aa21bb..ec8c68e 100644
--- a/em-format/e-mail-part.c
+++ b/em-format/e-mail-part.c
@@ -26,10 +26,15 @@
* message.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "e-mail-part.h"
#include <string.h>
+#include "e-mail-part-attachment.h"
#include "e-mail-part-list.h"
#define E_MAIL_PART_GET_PRIVATE(obj) \
@@ -441,6 +446,46 @@ e_mail_part_set_mime_type (EMailPart *part,
g_object_notify (G_OBJECT (part), "mime-type");
}
+gboolean
+e_mail_part_should_show_inline (EMailPart *part)
+{
+ CamelMimePart *mime_part;
+ const CamelContentDisposition *disposition;
+ gboolean res = FALSE;
+
+ g_return_val_if_fail (E_IS_MAIL_PART (part), FALSE);
+
+ /* Automatically expand attachments that have inline
+ * disposition or the EMailParts have specific
+ * force_inline flag set. */
+
+ if (part->force_collapse)
+ return FALSE;
+
+ if (part->force_inline)
+ return TRUE;
+
+ if (E_IS_MAIL_PART_ATTACHMENT (part)) {
+ EMailPartAttachment *empa = E_MAIL_PART_ATTACHMENT (part);
+
+ if (g_strcmp0 (empa->snoop_mime_type, "message/rfc822") == 0)
+ return TRUE;
+ }
+
+ mime_part = e_mail_part_ref_mime_part (part);
+ if (!mime_part)
+ return FALSE;
+
+ disposition = camel_mime_part_get_content_disposition (mime_part);
+ if (disposition && disposition->disposition &&
+ g_ascii_strncasecmp (disposition->disposition, "inline", 6) == 0)
+ res = TRUE;
+
+ g_object_unref (mime_part);
+
+ return res;
+}
+
EMailPartList *
e_mail_part_ref_part_list (EMailPart *part)
{
diff --git a/em-format/e-mail-part.h b/em-format/e-mail-part.h
index 63e8ae1..d4d0b3f 100644
--- a/em-format/e-mail-part.h
+++ b/em-format/e-mail-part.h
@@ -107,6 +107,7 @@ CamelMimePart * e_mail_part_ref_mime_part (EMailPart *part);
const gchar * e_mail_part_get_mime_type (EMailPart *part);
void e_mail_part_set_mime_type (EMailPart *part,
const gchar *mime_type);
+gboolean e_mail_part_should_show_inline (EMailPart *part);
struct _EMailPartList *
e_mail_part_ref_part_list (EMailPart *part);
void e_mail_part_set_part_list (EMailPart *part,
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 0640234..49478a0 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -580,6 +580,8 @@ attachment_button_expanded (GObject *object,
html_element = WEBKIT_DOM_HTML_ELEMENT (element);
webkit_dom_html_element_set_inner_html (html_element, inner_html_data, NULL);
+
+ webkit_dom_element_remove_attribute (element, "inner-html-data");
}
g_free (inner_html_data);
@@ -835,9 +837,6 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
e_mail_part_attachment_get_expandable (empa));
if (e_mail_part_attachment_get_expandable (empa)) {
- CamelMimePart *mime_part;
- const CamelContentDisposition *disposition;
-
/* Show/hide the attachment when the EAttachmentButton
* is expanded/collapsed or shown/hidden. */
g_signal_connect (
@@ -853,20 +852,7 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
G_CALLBACK (attachment_button_zoom_to_window_cb),
display);
- mime_part = e_mail_part_ref_mime_part (part);
-
- /* Automatically expand attachments that have inline
- * disposition or the EMailParts have specific
- * force_inline flag set. */
- disposition =
- camel_mime_part_get_content_disposition (mime_part);
- if (!part->force_collapse &&
- (part->force_inline ||
- (g_strcmp0 (empa->snoop_mime_type, "message/rfc822") == 0) ||
- (disposition && disposition->disposition &&
- g_ascii_strncasecmp (
- disposition->disposition, "inline", 6) == 0))) {
-
+ if (e_mail_part_should_show_inline (part)) {
e_attachment_button_set_expanded (
E_ATTACHMENT_BUTTON (widget), TRUE);
} else {
@@ -875,8 +861,6 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
attachment_button_expanded (
G_OBJECT (widget), NULL, display);
}
-
- g_object_unref (mime_part);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]