[evolution/wip/webkit2] Bug 759474 - Attachment Reminder plugin should ignore quoted message text



commit a913a7eeec79a9258478c43fb75368e3b1a38897
Author: Milan Crha <mcrha redhat com>
Date:   Thu Mar 3 15:30:01 2016 +0100

    Bug 759474 - Attachment Reminder plugin should ignore quoted message text

 plugins/attachment-reminder/attachment-reminder.c  |   19 +++++++++++++++++++
 .../composer/e-msg-composer-dom-functions.c        |   17 ++++++++++++-----
 2 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/plugins/attachment-reminder/attachment-reminder.c 
b/plugins/attachment-reminder/attachment-reminder.c
index 4966b21..0031c63 100644
--- a/plugins/attachment-reminder/attachment-reminder.c
+++ b/plugins/attachment-reminder/attachment-reminder.c
@@ -140,6 +140,23 @@ ask_for_missing_attachment (EPlugin *ep,
        return response == GTK_RESPONSE_YES;
 }
 
+static void
+censor_quoted_lines (GByteArray *msg_text)
+{
+       gchar *ptr;
+       gboolean in_quotation = FALSE;
+
+       g_return_if_fail (msg_text != NULL);
+
+       for (ptr = (char *) msg_text->data; ptr && *ptr; ptr++) {
+               if (*ptr == '\n') {
+                       in_quotation = ptr[1] == '>';
+               } else if (*ptr != '\r' && in_quotation) {
+                       *ptr = ' ';
+               }
+       }
+}
+
 /* check for the clues */
 static gboolean
 check_for_attachment_clues (GByteArray *msg_text)
@@ -160,6 +177,8 @@ check_for_attachment_clues (GByteArray *msg_text)
 
                g_byte_array_append (msg_text, (const guint8 *) "\0", 1);
 
+               censor_quoted_lines (msg_text);
+
                for (ii = 0; clue_list[ii] && !found; ii++) {
                        GString *word;
                        const gchar *clue = clue_list[ii];
diff --git a/web-extensions/composer/e-msg-composer-dom-functions.c 
b/web-extensions/composer/e-msg-composer-dom-functions.c
index cadb88e..2af4e11 100644
--- a/web-extensions/composer/e-msg-composer-dom-functions.c
+++ b/web-extensions/composer/e-msg-composer-dom-functions.c
@@ -65,13 +65,20 @@ dom_get_raw_body_content_without_signature (WebKitDOMDocument *document)
                document, "body > *:not(.-x-evo-signature-wrapper)", NULL);
        length = webkit_dom_node_list_get_length (list);
        for (ii = 0; ii < length; ii++) {
-               gchar *text;
                WebKitDOMNode *node = webkit_dom_node_list_item (list, ii);
 
-               text = webkit_dom_html_element_get_inner_text (
-                       WEBKIT_DOM_HTML_ELEMENT (node));
-               g_string_append (content, text);
-               g_free (text);
+               if (!WEBKIT_DOM_IS_HTML_QUOTE_ELEMENT (node)) {
+                       gchar *text;
+
+                       text = webkit_dom_html_element_get_inner_text (WEBKIT_DOM_HTML_ELEMENT (node));
+                       g_string_append (content, text);
+                       g_free (text);
+
+                       if (WEBKIT_DOM_IS_HTML_DIV_ELEMENT (node))
+                               g_string_append (content, "\n");
+                       else
+                               g_string_append (content, " ");
+               }
        }
 
        return g_string_free (content, FALSE);


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