[PATCH 1/2] Convert non-UTF-8 parts to UTF-8 before indexing them
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 24 Feb 2012 07:36:22 +0000 (08:36 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:53 +0000 (09:44 -0800)
c2/fb4b9228351aa1dca69e41d92ad53c8ca83b50 [new file with mode: 0644]

diff --git a/c2/fb4b9228351aa1dca69e41d92ad53c8ca83b50 b/c2/fb4b9228351aa1dca69e41d92ad53c8ca83b50
new file mode 100644 (file)
index 0000000..09e93e7
--- /dev/null
@@ -0,0 +1,103 @@
+Return-Path: <sojkam1@fel.cvut.cz>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7A2C1431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 23 Feb 2012 23:36:36 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id L1ZVK0O7IZbh for <notmuch@notmuchmail.org>;\r
+       Thu, 23 Feb 2012 23:36:35 -0800 (PST)\r
+Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
+       by olra.theworths.org (Postfix) with ESMTP id 69351431FBC\r
+       for <notmuch@notmuchmail.org>; Thu, 23 Feb 2012 23:36:35 -0800 (PST)\r
+Received: from localhost (unknown [192.168.200.4])\r
+       by max.feld.cvut.cz (Postfix) with ESMTP id AFFAB19F3399;\r
+       Fri, 24 Feb 2012 08:36:34 +0100 (CET)\r
+X-Virus-Scanned: IMAP AMAVIS\r
+Received: from max.feld.cvut.cz ([192.168.200.1])\r
+       by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
+       port 10044)\r
+       with ESMTP id tYAF04f-RUnu; Fri, 24 Feb 2012 08:36:30 +0100 (CET)\r
+Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
+       by max.feld.cvut.cz (Postfix) with ESMTP id CEE1E19F339E;\r
+       Fri, 24 Feb 2012 08:36:30 +0100 (CET)\r
+Received: from steelpick.2x.cz (cable-86-56-3-85.cust.telecolumbus.net\r
+       [86.56.3.85]) (Authenticated sender: sojkam1)\r
+       by imap.feld.cvut.cz (Postfix) with ESMTPSA id BA548660969;\r
+       Fri, 24 Feb 2012 08:36:30 +0100 (CET)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.77)\r
+       (envelope-from <sojkam1@fel.cvut.cz>)\r
+       id 1S0phd-0001B1-Vb; Fri, 24 Feb 2012 08:36:29 +0100\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] Convert non-UTF-8 parts to UTF-8 before indexing them\r
+Date: Fri, 24 Feb 2012 08:36:22 +0100\r
+Message-Id: <1330068983-4483-1-git-send-email-sojkam1@fel.cvut.cz>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1330043595-22054-1-git-send-email-sojkam1@fel.cvut.cz>\r
+References: <1330043595-22054-1-git-send-email-sojkam1@fel.cvut.cz>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 24 Feb 2012 07:36:36 -0000\r
+\r
+This fixes a bug that didn't allow to search for non-ASCII words such\r
+parts. The code here was copied from show_text_part_content(), because\r
+the show command already does the needed conversion when showing the\r
+message.\r
+---\r
+ lib/index.cc |   15 +++++++++++++++\r
+ 1 files changed, 15 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/lib/index.cc b/lib/index.cc\r
+index d8f8b2b..e377732 100644\r
+--- a/lib/index.cc\r
++++ b/lib/index.cc\r
+@@ -315,6 +315,7 @@ _index_mime_part (notmuch_message_t *message,\r
+     GByteArray *byte_array;\r
+     GMimeContentDisposition *disposition;\r
+     char *body;\r
++    const char *charset;\r
+ \r
+     if (! part) {\r
+       fprintf (stderr, "Warning: Not indexing empty mime part.\n");\r
+@@ -390,6 +391,20 @@ _index_mime_part (notmuch_message_t *message,\r
+     g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),\r
+                             discard_uuencode_filter);\r
+ \r
++    charset = g_mime_object_get_content_type_parameter (part, "charset");\r
++    if (charset) {\r
++      GMimeFilter *charset_filter;\r
++      charset_filter = g_mime_filter_charset_new (charset, "UTF-8");\r
++      /* This result can be NULL for things like "unknown-8bit".\r
++       * Don't set a NULL filter as that makes GMime print\r
++       * annoying assertion-failure messages on stderr. */\r
++      if (charset_filter) {\r
++          g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),\r
++                                    charset_filter);\r
++          g_object_unref (charset_filter);\r
++      }\r
++    }\r
++\r
+     wrapper = g_mime_part_get_content_object (GMIME_PART (part));\r
+     if (wrapper)\r
+       g_mime_data_wrapper_write_to_stream (wrapper, filter);\r
+-- \r
+1.7.9.1\r
+\r