1 Return-Path: <jani@nikula.org>
\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 olra.theworths.org (Postfix) with ESMTP id 00C21431FB6
\r
6 for <notmuch@notmuchmail.org>; Tue, 26 Feb 2013 01:19:23 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 7lMT0nEj4WZN for <notmuch@notmuchmail.org>;
\r
16 Tue, 26 Feb 2013 01:19:20 -0800 (PST)
\r
17 Received: from mail-we0-f175.google.com (mail-we0-f175.google.com
\r
18 [74.125.82.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 52D14431FAF
\r
21 for <notmuch@notmuchmail.org>; Tue, 26 Feb 2013 01:19:20 -0800 (PST)
\r
22 Received: by mail-we0-f175.google.com with SMTP id x8so3317447wey.6
\r
23 for <notmuch@notmuchmail.org>; Tue, 26 Feb 2013 01:19:17 -0800 (PST)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=x-received:from:to:subject:in-reply-to:references:user-agent:date
\r
27 :message-id:mime-version:content-type:x-gm-message-state;
\r
28 bh=fumzV0OKnmDWKk9etUJm2gd9dTO/IAToWlwm722R27Q=;
\r
29 b=l550UJYCKGunAujYO8aZVnSFVCGKoAEjkAGFiOijNfeyfSOUpnnTw1BDAIpcHNH55o
\r
30 uqWmLbVztjgJ/wlHaOBcNzGoaElHovcR/O9zZC4sjOCNJujVFcKOuPBJopRTiTibrl6F
\r
31 vz1LG+9R55TSmuQlQOhEg29SiYFdORNG1PMBKKY99zq0WdDdOAES2RJToAkyE3TPTy7o
\r
32 8VOtLmtQNPGYCjBTSPIZXGDJ+HL5Nd4nT+IKAh/mJNoMa6wsurNMeE1HyQPU4ApCMXu4
\r
33 /om6T1ohN8cWsBN7Mco+xSshgobofMjDectLbXsTYbaAfMCbO3YUNG7uAel/FhH7avnG
\r
35 X-Received: by 10.180.92.39 with SMTP id cj7mr17802562wib.19.1361870357808;
\r
36 Tue, 26 Feb 2013 01:19:17 -0800 (PST)
\r
37 Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])
\r
38 by mx.google.com with ESMTPS id bj9sm19843333wib.4.2013.02.26.01.19.15
\r
39 (version=TLSv1.1 cipher=RC4-SHA bits=128/128);
\r
40 Tue, 26 Feb 2013 01:19:16 -0800 (PST)
\r
41 From: Jani Nikula <jani@nikula.org>
\r
42 To: Aaron Ecay <aaronecay@gmail.com>, notmuch@notmuchmail.org
\r
43 Subject: Re: [RFC] [PATCH] lib/database.cc: change how the parent of a message
\r
45 In-Reply-To: <1361836225-17279-1-git-send-email-aaronecay@gmail.com>
\r
46 References: <1361836225-17279-1-git-send-email-aaronecay@gmail.com>
\r
47 User-Agent: Notmuch/0.14+259~gdee88db (http://notmuchmail.org) Emacs/23.2.1
\r
48 (x86_64-pc-linux-gnu)
\r
49 Date: Tue, 26 Feb 2013 10:19:06 +0100
\r
50 Message-ID: <878v6bjuut.fsf@nikula.org>
\r
52 Content-Type: text/plain; charset=us-ascii
\r
54 ALoCoQlx3ALbGyQhHxtVa2iEPQQ0nC850x2OiuzgcWKxG64wFqbLyFq+Uzo+nSwk1lSSdYs/S+Xe
\r
55 X-BeenThere: notmuch@notmuchmail.org
\r
56 X-Mailman-Version: 2.1.13
\r
58 List-Id: "Use and development of the notmuch mail system."
\r
59 <notmuch.notmuchmail.org>
\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
63 List-Post: <mailto:notmuch@notmuchmail.org>
\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
67 X-List-Received-Date: Tue, 26 Feb 2013 09:19:23 -0000
\r
69 On Tue, 26 Feb 2013, Aaron Ecay <aaronecay@gmail.com> wrote:
\r
70 > Presently, the code which finds the parent of a message as it is being
\r
71 > added to the database assumes that the first Message-ID-like substring
\r
72 > of the In-Reply-To header is the parent Message ID. Some mail clients,
\r
73 > however, put stuff other than the Message-ID of the parent in the
\r
74 > In-Reply-To header, such as the email address of the sender of the
\r
75 > parent. This can fool notmuch.
\r
77 Hi Aaron, please provide references to a few messages like this. If
\r
78 available on the notmuch list an id: reference would be best, but
\r
79 otherwise some archive that allows viewing full message headers or
\r
80 downloading the full message would be best.
\r
86 > The updated algorithm prefers the last Message ID in the References
\r
87 > header. The References header lists messages oldest-first, so the last
\r
88 > Message ID is the parent (RFC2822, p. 24). The References header is
\r
89 > also less likely to be in a non-standard
\r
90 > syntax (http://cr.yp.to/immhf/thread.html,
\r
91 > http://www.jwz.org/doc/threading.html). In case the References header
\r
92 > is not to be found, fall back to the old behavior.
\r
95 > I especially notice this problem on public mailing lists, where
\r
96 > certain people's messages always cause an "out-dent" of the threading,
\r
97 > instead of being nested under whichever message they are replies to.
\r
99 > Technically, putting non-Message-ID crud in the In-Reply-To field is a
\r
100 > violation of RFC2822, but it appears that in practice the References
\r
101 > header is respected more often than the In-Reply-To one.
\r
103 > lib/database.cc | 30 ++++++++++++++++++++++--------
\r
104 > 1 file changed, 22 insertions(+), 8 deletions(-)
\r
106 > diff --git a/lib/database.cc b/lib/database.cc
\r
107 > index 91d4329..cbf33ae 100644
\r
108 > --- a/lib/database.cc
\r
109 > +++ b/lib/database.cc
\r
110 > @@ -501,8 +501,10 @@ _parse_message_id (void *ctx, const char *message_id, const char **next)
\r
111 > * 'message_id' in the result (to avoid mass confusion when a single
\r
112 > * message references itself cyclically---and yes, mail messages are
\r
113 > * not infrequent in the wild that do this---don't ask me why).
\r
115 > + * Return the last reference parsed.
\r
119 > parse_references (void *ctx,
\r
120 > const char *message_id,
\r
121 > GHashTable *hash,
\r
122 > @@ -511,7 +513,7 @@ parse_references (void *ctx,
\r
125 > if (refs == NULL || *refs == '\0')
\r
130 > ref = _parse_message_id (ctx, refs, &refs);
\r
131 > @@ -519,6 +521,8 @@ parse_references (void *ctx,
\r
132 > if (ref && strcmp (ref, message_id))
\r
133 > g_hash_table_insert (hash, ref, NULL);
\r
140 > @@ -1365,7 +1369,7 @@ _notmuch_database_generate_doc_id (notmuch_database_t *notmuch)
\r
141 > notmuch->last_doc_id++;
\r
143 > if (notmuch->last_doc_id == 0)
\r
144 > - INTERNAL_ERROR ("Xapian document IDs are exhausted.\n");
\r
145 > + INTERNAL_ERROR ("Xapian document IDs are exhausted.\n");
\r
147 > return notmuch->last_doc_id;
\r
149 > @@ -1509,7 +1513,7 @@ _notmuch_database_link_message_to_parents (notmuch_database_t *notmuch,
\r
150 > const char **thread_id)
\r
152 > GHashTable *parents = NULL;
\r
153 > - const char *refs, *in_reply_to, *in_reply_to_message_id;
\r
154 > + const char *refs, *in_reply_to, *in_reply_to_message_id, *last_ref_message_id;
\r
155 > GList *l, *keys = NULL;
\r
156 > notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
\r
158 > @@ -1517,21 +1521,31 @@ _notmuch_database_link_message_to_parents (notmuch_database_t *notmuch,
\r
159 > _my_talloc_free_for_g_hash, NULL);
\r
161 > refs = notmuch_message_file_get_header (message_file, "references");
\r
162 > - parse_references (message, notmuch_message_get_message_id (message),
\r
163 > - parents, refs);
\r
164 > + last_ref_message_id = parse_references (message,
\r
165 > + notmuch_message_get_message_id (message),
\r
166 > + parents, refs);
\r
168 > in_reply_to = notmuch_message_file_get_header (message_file, "in-reply-to");
\r
169 > parse_references (message, notmuch_message_get_message_id (message),
\r
170 > parents, in_reply_to);
\r
172 > - /* Carefully avoid adding any self-referential in-reply-to term. */
\r
173 > in_reply_to_message_id = _parse_message_id (message, in_reply_to, NULL);
\r
174 > + /* If the parent message ID from the Reply-To and References
\r
175 > + * headers are different, use the References one. This is because
\r
176 > + * the Reply-To header is more likely to be in an non-standard
\r
178 > + if (in_reply_to_message_id &&
\r
179 > + last_ref_message_id &&
\r
180 > + strcmp (last_ref_message_id, in_reply_to_message_id)) {
\r
181 > + in_reply_to_message_id = last_ref_message_id;
\r
183 > + /* Carefully avoid adding any self-referential in-reply-to term. */
\r
184 > if (in_reply_to_message_id &&
\r
185 > strcmp (in_reply_to_message_id,
\r
186 > notmuch_message_get_message_id (message)))
\r
188 > _notmuch_message_add_term (message, "replyto",
\r
189 > - _parse_message_id (message, in_reply_to, NULL));
\r
190 > + in_reply_to_message_id);
\r
193 > keys = g_hash_table_get_keys (parents);
\r
196 > _______________________________________________
\r
197 > notmuch mailing list
\r
198 > notmuch@notmuchmail.org
\r
199 > http://notmuchmail.org/mailman/listinfo/notmuch
\r