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 D1AFE6DE1587 for ; Mon, 24 Jun 2019 18:41:21 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.554 X-Spam-Level: X-Spam-Status: No, score=-0.554 tagged_above=-999 required=5 tests=[AWL=0.347, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] 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 Dp94-kRDjeNs for ; Mon, 24 Jun 2019 18:41:18 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id 4ECFC6DE146C for ; Mon, 24 Jun 2019 18:41:16 -0700 (PDT) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/simple; d=fifthhorseman.net; i=@fifthhorseman.net; q=dns/txt; s=2019; t=1561426874; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=qmZtQB+y/v/mL8XE+RZXFYZK//uTwxSGm5meOe23OzA=; b=kplrWzb2mtU6m8pCGIU4y2f0AHInl3wx5VCph9oDFIvRDnXtf7RHLdGH 6fV9GWKD6NXdht2rwLHwNwK57raKCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fifthhorseman.net; i=@fifthhorseman.net; q=dns/txt; s=2019rsa; t=1561426874; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=qmZtQB+y/v/mL8XE+RZXFYZK//uTwxSGm5meOe23OzA=; b=Eo86FsrnxtKpgdtER6R6jSlSp3k39bsekZPaNQwWLlQn1M1rVs5NNoYQ ZmZZ6bBFrPY//ReLaKY55q8OUsMpKSs68m5jd5p3G7d7rV5/YrqCHsClFq b1p+bGWeUvpQcT+ZH7UX+Zsv9RZYH/OTMk4Q43i2yQBCKqHA9kGAbrd+fi /5Dnt2QiZ/ZhTcMVqWidCmm2ikdMi3u1I6we6bb4Io+Weo/U0qu5NT4WGl caPNZzp6wri999Aj3mLKn+w/3d4LrpCs1ltH3+kSk371hjF07j+eVy3pYr eA5sjEAUdXPLh7JzII+c+cnl0+ENccEEMUhi0wMxz8LEIlIG6S26EQ== Received: from fifthhorseman.net (unknown [38.109.115.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by che.mayfirst.org (Postfix) with ESMTPSA id 85196F9A2 for ; Mon, 24 Jun 2019 21:41:14 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 254DC20B28; Mon, 24 Jun 2019 21:41:12 -0400 (EDT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH 7/7] index: avoid indexing legacy-display parts Date: Mon, 24 Jun 2019 21:41:07 -0400 Message-Id: <20190625014107.12452-8-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190625014107.12452-1-dkg@fifthhorseman.net> References: <20190625014107.12452-1-dkg@fifthhorseman.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 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: Tue, 25 Jun 2019 01:41:21 -0000 When we notice a legacy-display part during indexing, it makes more sense to avoid indexing it as part of the message body. Given that the protected subject will already be indexed, there is no need to index this part at all, so we skip over it. If this happens during indexing, we set a property on the message: index.repaired=skip-protected-headers-legacy-display Signed-off-by: Daniel Kahn Gillmor --- doc/man7/notmuch-properties.rst | 6 ++++++ lib/index.cc | 20 ++++++++++++++++---- test/T356-protected-headers.sh | 2 -- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/doc/man7/notmuch-properties.rst b/doc/man7/notmuch-properties.rst index 2e610683..e2db2ef5 100644 --- a/doc/man7/notmuch-properties.rst +++ b/doc/man7/notmuch-properties.rst @@ -121,6 +121,12 @@ of its normal activity. ``index.repaired`` property to note the type of repair(s) it performed. + ``index.repaired=skip-protected-headers-legacy-display`` indicates + that when indexing the cleartext of an encrypted message, notmuch + skipped over a "legacy-display" text/rfc822-headers part that it + found in that message, since it was able to index the built-in + protected headers directly. + SEE ALSO ======== diff --git a/lib/index.cc b/lib/index.cc index 8a3e2e09..1301d78a 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -435,8 +435,14 @@ _index_mime_part (notmuch_message_t *message, continue; } child = g_mime_multipart_get_part (multipart, i); - _notmuch_message_crypto_potential_payload (msg_crypto, child, part, i); - _index_mime_part (message, indexopts, child, msg_crypto); + GMimeObject *toindex = child; + if (_notmuch_message_crypto_potential_payload (msg_crypto, child, part, i) && + msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) { + toindex = _notmuch_repair_crypto_payload_skip_legacy_display (child); + if (toindex != child) + notmuch_message_add_property (message, "index.repaired", "skip-protected-headers-legacy-display"); + } + _index_mime_part (message, indexopts, toindex, msg_crypto); } return; } @@ -573,8 +579,14 @@ _index_encrypted_mime_part (notmuch_message_t *message, } g_object_unref (decrypt_result); } - _notmuch_message_crypto_potential_payload (msg_crypto, clear, GMIME_OBJECT (encrypted_data), GMIME_MULTIPART_ENCRYPTED_CONTENT); - _index_mime_part (message, indexopts, clear, msg_crypto); + GMimeObject *toindex = clear; + if (_notmuch_message_crypto_potential_payload (msg_crypto, clear, GMIME_OBJECT (encrypted_data), GMIME_MULTIPART_ENCRYPTED_CONTENT) && + msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) { + toindex = _notmuch_repair_crypto_payload_skip_legacy_display (clear); + if (toindex != clear) + notmuch_message_add_property (message, "index.repaired", "skip-protected-headers-legacy-display"); + } + _index_mime_part (message, indexopts, toindex, msg_crypto); g_object_unref (clear); status = notmuch_message_add_property (message, "index.decryption", "success"); diff --git a/test/T356-protected-headers.sh b/test/T356-protected-headers.sh index 867b8722..925805df 100755 --- a/test/T356-protected-headers.sh +++ b/test/T356-protected-headers.sh @@ -148,12 +148,10 @@ test_json_nodes <<<"$output" \ 'no_legacy_display:["original"]["body"][0]["content"][1]["content-type"]="text/plain"' test_begin_subtest "do not treat legacy-display part as body when indexing" -test_subtest_known_broken output=$(notmuch search --output=messages body:interrupting) test_expect_equal "$output" '' test_begin_subtest "identify message that had a legacy display part skipped during indexing" -test_subtest_known_broken output=$(notmuch search --output=messages property:index.repaired=skip-protected-headers-legacy-display) test_expect_equal "$output" id:protected-with-legacy-display@crypto.notmuchmail.org -- 2.20.1