--- /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 DC1616DE1416\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:22 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.023\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.023 tagged_above=-999 required=5\r
+ tests=[AWL=-0.023] 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 ffcvkxF1Shln for <notmuch@notmuchmail.org>;\r
+ Tue, 19 Jan 2016 18:53:19 -0800 (PST)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 036D06DE1557\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:16 -0800 (PST)\r
+Received: from fifthhorseman.net (unknown [38.109.115.130])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id D08EBF999\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 21:53:13 -0500 (EST)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id E9A5320698; Tue, 19 Jan 2016 18:53:10 -0800 (PST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v2 08/16] reorganize indexing of multipart/signed and\r
+ multipart/encrypted\r
+Date: Tue, 19 Jan 2016 21:52:41 -0500\r
+Message-Id: <1453258369-7366-9-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.7.0.rc3\r
+In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1453258369-7366-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: Wed, 20 Jan 2016 02:53:23 -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 | 39 +++++++++++++++++++--------------------\r
+ 1 file changed, 19 insertions(+), 20 deletions(-)\r
+\r
+diff --git a/lib/index.cc b/lib/index.cc\r
+index f166aef..ab0fd78 100644\r
+--- a/lib/index.cc\r
++++ b/lib/index.cc\r
+@@ -333,27 +333,26 @@ _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
++ _notmuch_message_add_term (message, "tag", "encrypted");\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.7.0.rc3\r
+\r