[PATCH v3 08/16] reorganize indexing of multipart/signed and multipart/encrypted
[notmuch-archives.git] / 2a / 69d8389e7562e5211cf029a1d10ca93b3553b1
1 Return-Path: <dkg@fifthhorseman.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id 693986DE0C5F\r
6  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 12:40:15 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12  autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id 3ynY149BZW-l for <notmuch@notmuchmail.org>;\r
16  Sun, 31 Jan 2016 12:40:13 -0800 (PST)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id 7F7736DE1AB6\r
19  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 12:40:09 -0800 (PST)\r
20 Received: from fifthhorseman.net (ip-64-134-185-108.public.wayport.net\r
21  [64.134.185.108])\r
22  by che.mayfirst.org (Postfix) with ESMTPSA id 5E5F9F99C\r
23  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 15:40:06 -0500 (EST)\r
24 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
25  id 4A54720FA6; Sun, 31 Jan 2016 15:40:06 -0500 (EST)\r
26 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
27 To: Notmuch Mail <notmuch@notmuchmail.org>\r
28 Subject: [PATCH v3 08/16] reorganize indexing of multipart/signed and\r
29  multipart/encrypted\r
30 Date: Sun, 31 Jan 2016 15:39:53 -0500\r
31 Message-Id: <1454272801-23623-9-git-send-email-dkg@fifthhorseman.net>\r
32 X-Mailer: git-send-email 2.7.0.rc3\r
33 In-Reply-To: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net>\r
34 References: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.20\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39  <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
46  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Sun, 31 Jan 2016 20:40:15 -0000\r
48 \r
49 This prepares the codebase for a cleaner changeset for dealing with\r
50 indexing some encrypted messages in the clear.\r
51 ---\r
52  lib/index.cc | 39 +++++++++++++++++++--------------------\r
53  1 file changed, 19 insertions(+), 20 deletions(-)\r
54 \r
55 diff --git a/lib/index.cc b/lib/index.cc\r
56 index f166aef..ab0fd78 100644\r
57 --- a/lib/index.cc\r
58 +++ b/lib/index.cc\r
59 @@ -333,27 +333,26 @@ _index_mime_part (notmuch_message_t *message,\r
60         GMimeMultipart *multipart = GMIME_MULTIPART (part);\r
61         int i;\r
62  \r
63 -       if (GMIME_IS_MULTIPART_SIGNED (multipart))\r
64 -         _notmuch_message_add_term (message, "tag", "signed");\r
65 -\r
66 -       if (GMIME_IS_MULTIPART_ENCRYPTED (multipart))\r
67 -         _notmuch_message_add_term (message, "tag", "encrypted");\r
68 -\r
69 -       for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {\r
70 -           if (GMIME_IS_MULTIPART_SIGNED (multipart)) {\r
71 -               /* Don't index the signature. */\r
72 -               if (i == 1)\r
73 -                   continue;\r
74 -               if (i > 1)\r
75 -                   _notmuch_database_log (_notmuch_message_database (message),\r
76 -                                         "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n");\r
77 -           }\r
78 -           if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {\r
79 -               /* Don't index encrypted parts. */\r
80 -               continue;\r
81 -           }\r
82 +       if (GMIME_IS_MULTIPART_SIGNED (multipart)) {\r
83 +           _notmuch_message_add_term (message, "tag", "signed");\r
84 +           /* FIXME: should we try to validate the signature? */\r
85 +           \r
86 +           /* FIXME: is it always just the first part that is signed in\r
87 +            all multipart/signed messages?*/\r
88             _index_mime_part (message,\r
89 -                             g_mime_multipart_get_part (multipart, i));\r
90 +                             g_mime_multipart_get_part (multipart, 0));\r
91 +           \r
92 +           if (g_mime_multipart_get_count (multipart) > 2)\r
93 +               _notmuch_database_log (_notmuch_message_database (message),\r
94 +                                      "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n");\r
95 +       } else if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {\r
96 +           /* Don't index encrypted parts */\r
97 +           _notmuch_message_add_term (message, "tag", "encrypted");\r
98 +       } else {\r
99 +           for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {\r
100 +               _index_mime_part (message,\r
101 +                                 g_mime_multipart_get_part (multipart, i));\r
102 +           }\r
103         }\r
104         return;\r
105      }\r
106 -- \r
107 2.7.0.rc3\r
108 \r