From 2b44683cb7ed0472400d61d622e57e7c1abf4270 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Wed, 20 Jan 2016 21:52:41 +1900 Subject: [PATCH] [PATCH v2 08/16] reorganize indexing of multipart/signed and multipart/encrypted --- b8/b455f58b12911ea0807646f8c2f8b6c9c5be72 | 107 ++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 b8/b455f58b12911ea0807646f8c2f8b6c9c5be72 diff --git a/b8/b455f58b12911ea0807646f8c2f8b6c9c5be72 b/b8/b455f58b12911ea0807646f8c2f8b6c9c5be72 new file mode 100644 index 000000000..901f4ddc5 --- /dev/null +++ b/b8/b455f58b12911ea0807646f8c2f8b6c9c5be72 @@ -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 DC1616DE1416 + for ; Tue, 19 Jan 2016 18:53:22 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.023 +X-Spam-Level: +X-Spam-Status: No, score=-0.023 tagged_above=-999 required=5 + tests=[AWL=-0.023] 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 ffcvkxF1Shln for ; + Tue, 19 Jan 2016 18:53:19 -0800 (PST) +Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108]) + by arlo.cworth.org (Postfix) with ESMTP id 036D06DE1557 + for ; Tue, 19 Jan 2016 18:53:16 -0800 (PST) +Received: from fifthhorseman.net (unknown [38.109.115.130]) + by che.mayfirst.org (Postfix) with ESMTPSA id D08EBF999 + for ; Tue, 19 Jan 2016 21:53:13 -0500 (EST) +Received: by fifthhorseman.net (Postfix, from userid 1000) + id E9A5320698; Tue, 19 Jan 2016 18:53:10 -0800 (PST) +From: Daniel Kahn Gillmor +To: Notmuch Mail +Subject: [PATCH v2 08/16] reorganize indexing of multipart/signed and + multipart/encrypted +Date: Tue, 19 Jan 2016 21:52:41 -0500 +Message-Id: <1453258369-7366-9-git-send-email-dkg@fifthhorseman.net> +X-Mailer: git-send-email 2.7.0.rc3 +In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net> +References: <1453258369-7366-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: Wed, 20 Jan 2016 02:53:23 -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 f166aef..ab0fd78 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.7.0.rc3 + -- 2.26.2