[evolution-data-server] Bug 700015 - Searching for mail contents does not respect encoding



commit 9f7d7a7797fa263eacad9cc91af87dd584f97184
Author: Milan Crha <mcrha redhat com>
Date:   Thu Mar 12 17:48:50 2015 +0100

    Bug 700015 - Searching for mail contents does not respect encoding

 camel/camel-folder-search.c  |   17 +++++++++++++++++
 camel/camel-search-private.c |   18 ++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index 1ee79a6..1c43999 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -514,10 +514,27 @@ match_words_1message (CamelDataWrapper *object,
                /* for all other text parts, we look inside, otherwise we dont care */
                CamelStream *stream;
                GByteArray *byte_array;
+               const gchar *charset;
 
                byte_array = g_byte_array_new ();
                stream = camel_stream_mem_new_with_byte_array (byte_array);
 
+               charset = camel_content_type_param (CAMEL_DATA_WRAPPER (containee)->mime_type, "charset");
+               if (charset && *charset) {
+                       CamelMimeFilter *filter = camel_mime_filter_charset_new (charset, "UTF-8");
+                       if (filter) {
+                               CamelStream *filtered = camel_stream_filter_new (stream);
+
+                               if (filtered) {
+                                       camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered), filter);
+                                       g_object_unref (stream);
+                                       stream = filtered;
+                               }
+
+                               g_object_unref (filter);
+                       }
+               }
+
                /* FIXME The match should be part of a stream op */
                camel_data_wrapper_decode_to_stream_sync (
                        containee, stream, cancellable, NULL);
diff --git a/camel/camel-search-private.c b/camel/camel-search-private.c
index b7dba5d..0126ef3 100644
--- a/camel/camel-search-private.c
+++ b/camel/camel-search-private.c
@@ -532,9 +532,27 @@ camel_search_message_body_contains (CamelDataWrapper *object,
                 * inside, otherwise we don't care. */
                CamelStream *stream;
                GByteArray *byte_array;
+               const gchar *charset;
 
                byte_array = g_byte_array_new ();
                stream = camel_stream_mem_new_with_byte_array (byte_array);
+
+               charset = camel_content_type_param (CAMEL_DATA_WRAPPER (containee)->mime_type, "charset");
+               if (charset && *charset) {
+                       CamelMimeFilter *filter = camel_mime_filter_charset_new (charset, "UTF-8");
+                       if (filter) {
+                               CamelStream *filtered = camel_stream_filter_new (stream);
+
+                               if (filtered) {
+                                       camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered), filter);
+                                       g_object_unref (stream);
+                                       stream = filtered;
+                               }
+
+                               g_object_unref (filter);
+                       }
+               }
+
                camel_data_wrapper_decode_to_stream_sync (
                        containee, stream, NULL, NULL);
                camel_stream_write (stream, "", 1, NULL, NULL);


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