--- /dev/null
+Return-Path: <dkg@fifthhorseman.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 2A4796DE1601\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:12 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.034\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.034 tagged_above=-999 required=5\r
+ tests=[AWL=-0.034] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id y4EAL1bUZIj0 for <notmuch@notmuchmail.org>;\r
+ Wed, 9 Dec 2015 19:40:10 -0800 (PST)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 9FE736DE1737\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:05 -0800 (PST)\r
+Received: from fifthhorseman.net (unknown [38.109.115.130])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 68F42F98B\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 22:40:04 -0500 (EST)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id A0BB91FEDC; Wed, 9 Dec 2015 22:40:03 -0500 (EST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH 1/9] reorganize indexing of multipart/signed and\r
+ multipart/encrypted\r
+Date: Wed, 9 Dec 2015 22:39:38 -0500\r
+Message-Id: <1449718786-28000-2-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.6.2\r
+In-Reply-To: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 10 Dec 2015 03:40:12 -0000\r
+\r
+This prepares the codebase for a cleaner changeset for dealing with\r
+indexing some encrypted messages in the clear.\r
+---\r
+ lib/index.cc | 38 ++++++++++++++++++--------------------\r
+ 1 file changed, 18 insertions(+), 20 deletions(-)\r
+\r
+diff --git a/lib/index.cc b/lib/index.cc\r
+index f166aef..2fa6616 100644\r
+--- a/lib/index.cc\r
++++ b/lib/index.cc\r
+@@ -333,27 +333,25 @@ _index_mime_part (notmuch_message_t *message,\r
+ GMimeMultipart *multipart = GMIME_MULTIPART (part);\r
+ int i;\r
+ \r
+- if (GMIME_IS_MULTIPART_SIGNED (multipart))\r
+- _notmuch_message_add_term (message, "tag", "signed");\r
+-\r
+- if (GMIME_IS_MULTIPART_ENCRYPTED (multipart))\r
+- _notmuch_message_add_term (message, "tag", "encrypted");\r
+-\r
+- for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {\r
+- if (GMIME_IS_MULTIPART_SIGNED (multipart)) {\r
+- /* Don't index the signature. */\r
+- if (i == 1)\r
+- continue;\r
+- if (i > 1)\r
+- _notmuch_database_log (_notmuch_message_database (message),\r
+- "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n");\r
+- }\r
+- if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {\r
+- /* Don't index encrypted parts. */\r
+- continue;\r
+- }\r
++ if (GMIME_IS_MULTIPART_SIGNED (multipart)) {\r
++ _notmuch_message_add_term (message, "tag", "signed");\r
++ /* FIXME: should we try to validate the signature? */\r
++ \r
++ /* FIXME: is it always just the first part that is signed in\r
++ all multipart/signed messages?*/\r
+ _index_mime_part (message,\r
+- g_mime_multipart_get_part (multipart, i));\r
++ g_mime_multipart_get_part (multipart, 0));\r
++ \r
++ if (g_mime_multipart_get_count (multipart) > 2)\r
++ _notmuch_database_log (_notmuch_message_database (message),\r
++ "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n");\r
++ } else if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {\r
++ /* Don't index encrypted parts */\r
++ } else {\r
++ for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {\r
++ _index_mime_part (message,\r
++ g_mime_multipart_get_part (multipart, i));\r
++ }\r
+ }\r
+ return;\r
+ }\r
+-- \r
+2.6.2\r
+\r