From: Daniel Kahn Gillmor Date: Fri, 8 Jul 2016 09:27:19 +0000 (+0200) Subject: [PATCH v4 08/16] reorganize indexing of multipart/signed and multipart/encrypted X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1cd3d974b32bf9b041bb8528c0c6ea974c54f8d4;p=notmuch-archives.git [PATCH v4 08/16] reorganize indexing of multipart/signed and multipart/encrypted --- diff --git a/3a/036f16e7e6f0fc8fcfd80ce93893bff5634475 b/3a/036f16e7e6f0fc8fcfd80ce93893bff5634475 new file mode 100644 index 000000000..3674c33df --- /dev/null +++ b/3a/036f16e7e6f0fc8fcfd80ce93893bff5634475 @@ -0,0 +1,107 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 05CF96DE09D9 + for ; Fri, 8 Jul 2016 03:14:00 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.049 +X-Spam-Level: +X-Spam-Status: No, score=0.049 tagged_above=-999 required=5 tests=[AWL=0.049] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id PLsih2GgQyOT for ; + Fri, 8 Jul 2016 03:13:49 -0700 (PDT) +Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) + by arlo.cworth.org (Postfix) with ESMTP id 603446DE0361 + for ; Fri, 8 Jul 2016 03:13:12 -0700 (PDT) +Received: from fifthhorseman.net (unknown [88.128.80.54]) + by che.mayfirst.org (Postfix) with ESMTPSA id C4D12F99B + for ; Fri, 8 Jul 2016 06:13:11 -0400 (EDT) +Received: by fifthhorseman.net (Postfix, from userid 1000) + id AAB5721248; Fri, 8 Jul 2016 11:27:34 +0200 (CEST) +From: Daniel Kahn Gillmor +To: Notmuch Mail +Subject: [PATCH v4 08/16] reorganize indexing of multipart/signed and + multipart/encrypted +Date: Fri, 8 Jul 2016 11:27:19 +0200 +Message-Id: <1467970047-8013-9-git-send-email-dkg@fifthhorseman.net> +X-Mailer: git-send-email 2.8.1 +In-Reply-To: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net> +References: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 08 Jul 2016 10:14:00 -0000 + +This prepares the codebase for a cleaner changeset for dealing with +indexing some encrypted messages in the clear. +--- + lib/index.cc | 39 +++++++++++++++++++-------------------- + 1 file changed, 19 insertions(+), 20 deletions(-) + +diff --git a/lib/index.cc b/lib/index.cc +index 8c14554..1c030a6 100644 +--- a/lib/index.cc ++++ b/lib/index.cc +@@ -333,27 +333,26 @@ _index_mime_part (notmuch_message_t *message, + GMimeMultipart *multipart = GMIME_MULTIPART (part); + int i; + +- if (GMIME_IS_MULTIPART_SIGNED (multipart)) +- _notmuch_message_add_term (message, "tag", "signed"); +- +- if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) +- _notmuch_message_add_term (message, "tag", "encrypted"); +- +- for (i = 0; i < g_mime_multipart_get_count (multipart); i++) { +- if (GMIME_IS_MULTIPART_SIGNED (multipart)) { +- /* Don't index the signature. */ +- if (i == 1) +- continue; +- if (i > 1) +- _notmuch_database_log (_notmuch_message_database (message), +- "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n"); +- } +- if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) { +- /* Don't index encrypted parts. */ +- continue; +- } ++ if (GMIME_IS_MULTIPART_SIGNED (multipart)) { ++ _notmuch_message_add_term (message, "tag", "signed"); ++ /* FIXME: should we try to validate the signature? */ ++ ++ /* FIXME: is it always just the first part that is signed in ++ all multipart/signed messages?*/ + _index_mime_part (message, +- g_mime_multipart_get_part (multipart, i)); ++ g_mime_multipart_get_part (multipart, 0)); ++ ++ if (g_mime_multipart_get_count (multipart) > 2) ++ _notmuch_database_log (_notmuch_message_database (message), ++ "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n"); ++ } else if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) { ++ /* Don't index encrypted parts */ ++ _notmuch_message_add_term (message, "tag", "encrypted"); ++ } else { ++ for (i = 0; i < g_mime_multipart_get_count (multipart); i++) { ++ _index_mime_part (message, ++ g_mime_multipart_get_part (multipart, i)); ++ } + } + return; + } +-- +2.8.1 +