From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 2A4796DE1601 for ; Wed, 9 Dec 2015 19:40:12 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.034 X-Spam-Level: X-Spam-Status: No, score=-0.034 tagged_above=-999 required=5 tests=[AWL=-0.034] 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 y4EAL1bUZIj0 for ; Wed, 9 Dec 2015 19:40:10 -0800 (PST) Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108]) by arlo.cworth.org (Postfix) with ESMTP id 9FE736DE1737 for ; Wed, 9 Dec 2015 19:40:05 -0800 (PST) Received: from fifthhorseman.net (unknown [38.109.115.130]) by che.mayfirst.org (Postfix) with ESMTPSA id 68F42F98B for ; Wed, 9 Dec 2015 22:40:04 -0500 (EST) Received: by fifthhorseman.net (Postfix, from userid 1000) id A0BB91FEDC; Wed, 9 Dec 2015 22:40:03 -0500 (EST) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH 1/9] reorganize indexing of multipart/signed and multipart/encrypted Date: Wed, 9 Dec 2015 22:39:38 -0500 Message-Id: <1449718786-28000-2-git-send-email-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net> References: <1449718786-28000-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: Thu, 10 Dec 2015 03:40:12 -0000 This prepares the codebase for a cleaner changeset for dealing with indexing some encrypted messages in the clear. --- lib/index.cc | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/index.cc b/lib/index.cc index f166aef..2fa6616 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -333,27 +333,25 @@ _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 */ + } 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.6.2