From 132a0a1482df16499056a34d7a59d8a4aa1413d7 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 17 Jun 2016 11:44:19 +0300 Subject: [PATCH] Re: notmuch reply is confused about multiple (or case-insensitive?) cc headers --- 1a/2cada74124ed54f625ac291403d8d0c97bc5e4 | 199 ++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 1a/2cada74124ed54f625ac291403d8d0c97bc5e4 diff --git a/1a/2cada74124ed54f625ac291403d8d0c97bc5e4 b/1a/2cada74124ed54f625ac291403d8d0c97bc5e4 new file mode 100644 index 000000000..9e7c86842 --- /dev/null +++ b/1a/2cada74124ed54f625ac291403d8d0c97bc5e4 @@ -0,0 +1,199 @@ +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 02BA36DE01F7 + for ; Fri, 17 Jun 2016 01:45:54 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.535 +X-Spam-Level: +X-Spam-Status: No, score=0.535 tagged_above=-999 required=5 tests=[AWL=1.255, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] 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 W02p-krQCg6m for ; + Fri, 17 Jun 2016 01:45:45 -0700 (PDT) +Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com + [74.125.82.45]) by arlo.cworth.org (Postfix) with ESMTPS id 3A4546DE00EB for + ; Fri, 17 Jun 2016 01:45:45 -0700 (PDT) +Received: by mail-wm0-f45.google.com with SMTP id a66so91091843wme.0 + for ; Fri, 17 Jun 2016 01:45:45 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=nikula-org.20150623.gappssmtp.com; s=20150623; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version; bh=NeRLVwI1Ybr1HeFKBdB1Xk+QhMtGlBUrRfAJ9bNRcIk=; + b=NeBdpeRqwbHodDRqXJfehRbmywzzcR396O7g3PzilYskcqjzJdDthtjJD+3M7z01+I + qv9oAHz6z7bQA4vrNKjn3F18auaiAG4/vpGXnfuWIpt6d/ulJiErPCOUaub/HAR97Xqg + wepmxehTr6iICfjFVWToW0KPmH172EleEuVcvXZHaGbyw8parLWx5JdXpqMmQs1ojkIp + 8d7REkOo/qIHZuimRtnMheXIQTBiN+CmE0K2oYxf7g2U3BRKyo0v7mTEILL3pX/5IMIB + YeKH0zh0q7U3+GDIiAkVt8eQBTv3yZlY4bTGLcfU2dO2BqAAreU6Ju/Siimnp7oJVP7e + u00g== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:in-reply-to:references + :user-agent:date:message-id:mime-version; + bh=NeRLVwI1Ybr1HeFKBdB1Xk+QhMtGlBUrRfAJ9bNRcIk=; + b=OfCVTah90FB0R7eCzv5N94InJc5KxIxolPP+96vKtVwHTLi8CEA1RnL2FACfq/GQhy + p9RPaEXm9q/D4Tkif0XV9im4u/EpQvLOn82en96meCGzWIyo4SL6HLQjei5DmAaRjRA3 + LPfrdCaXH5p/klyvW5LvVu44ZEhochgu6jaWvuxPCKxE8pEOhNLVulUQLl37U8gBoeos + eMd2LnwUBUo1MKzzPw/UNdVLb3tFr6kET0ZAFFrS2tDj8pqBVk8HIidvPd0AXcqDggAl + fASytJVI+xApfufHcb+HuN6WFtI3Zx5CvKJRIMN/w3ynvTETFHj6W8cUY5jy8rpsoRtO + +TVw== +X-Gm-Message-State: + ALyK8tIbePDJBeWWjBbNw0Ibjntk3OEJP+3S8A15MUNQNlg4gauEpm9/0egRrKVXfYHfxA== +X-Received: by 10.28.212.198 with SMTP id l189mr20398219wmg.100.1466153143199; + Fri, 17 Jun 2016 01:45:43 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw2-58c37a-44.dhcp.inet.fi. + [88.195.122.44]) + by smtp.gmail.com with ESMTPSA id zg10sm23283452wjb.1.2016.06.17.01.45.42 + (version=TLSv1/SSLv3 cipher=OTHER); + Fri, 17 Jun 2016 01:45:42 -0700 (PDT) +From: Jani Nikula +To: Daniel Kahn Gillmor , + Notmuch Mail +Subject: Re: notmuch reply is confused about multiple (or case-insensitive?) + cc headers +In-Reply-To: <87d1ngv95p.fsf@alice.fifthhorseman.net> +References: <87d1ngv95p.fsf@alice.fifthhorseman.net> +User-Agent: Notmuch/0.22+35~g6a833a6 (https://notmuchmail.org) Emacs/24.4.1 + (x86_64-pc-linux-gnu) +Date: Fri, 17 Jun 2016 11:44:19 +0300 +Message-ID: <87bn30tdb0.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain +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: Fri, 17 Jun 2016 08:45:54 -0000 + +On Fri, 17 Jun 2016, Daniel Kahn Gillmor wrote: +> hey notmuchers-- +> +> I'm using notmuch from close to git master. +> +> I just received an e-mail with headers like this: +> +> ------ +> From: Alice +> To: Daniel Kahn Gillmor +> Cc: Bob +> Subject: wowsers! +> cc: Charles +> Message-Id: +> Date: Thu, 16 Jun 2016 22:14:41 -0400 +> +> blah blah +> ------ +> +> Note the weirdness about the Cc fields! +> +> https://tools.ietf.org/html/rfc5322#page-21 +> +> Makes it clear that there is supposed to only be zero or one cc header +> in an e-mail, but notmuch-emacs is nice enough to show me both. +> +> However, if i do: +> +> notmuch reply id:abc123@example.org +> +> then Charles is omitted: +> +> ---------- +> From: Daniel Kahn Gillmor +> Subject: Re: wowsers! +> To: Alice +> Cc: Bob +> In-Reply-To: +> References: +> +> On Thu, 16 Jun 2016 22:14:41 -0400, Alice wrote: +>> blah blah +> ---------- +> +> +> In json form: +> +> 0 dkg@alice:~$ notmuch reply --format=json id:abc123@example.org | json_pp +> { +> "reply-headers" : { +> "From" : "Daniel Kahn Gillmor ", +> "References" : "", +> "To" : "Alice ", +> "Cc" : "Bob ", +> "Subject" : "Re: wowsers!", +> "In-reply-to" : "" +> }, +> "original" : { +> "id" : "abc123@example.org", +> "filename" : "REDACTED", +> "timestamp" : 1466129681, +> "match" : false, +> "headers" : { +> "Cc" : "Bob , Charles ", +> "Date" : "", +> "Subject" : "wowsers!", +> "From" : "Alice ", +> "To" : "Daniel Kahn Gillmor " +> }, +> "tags" : [], +> "excluded" : false" +> ... +> +> +> +> Note that we see Charles in original[headers[Cc]], but not in +> reply-headers[Cc]. +> +> Seems to me like these two should agree. We should either decide to +> take the strict interpretation of RFC 5322 or not. I lean toward +> including Charles in both sets, fwiw. + +The two come from code paths surprisingly far away from each other. + +The original message is formatted using the message printing in +notmuch-show.c. For Cc:, it uses g_mime_message_get_recipients(), which +apparently combines all Cc: fields into one internally. + +The addresses in the reply headers, OTOH, are based on headers queried +through libnotmuch. It boils down to g_mime_object_get_header() in +lib/message-file.c, which returns only the first occurence of header. + +> Anyway, smells like a bug in a weird corner case, and i haven't had time +> to track it down or fix it, but i figured i'd report it so that other +> people can see it. + +I don't think I'd do anything to fix this particular issue. It's a +corner case, we comply with the RFC, and all that. + +However, I would start thinking about our usage of gmime directly +vs. querying through the lib in the cli. The lib has some caching for +efficiency, and is probably the way to go for indexing and searching +etc. But perhaps we should just hit the disk directly using gmime when +we're reading and parsing the messages to show in the cli? So perhaps we +should be using gmime calls instead of notmuch lib calls to get the +from/to/cc headers in notmuch reply, for example. This would fix the +issue as a side effect. (You could argue we should do this just to fix +this bug, but I think it's a bigger design decision.) + +Side note #1, even in the indexing code in the lib we use +g_mime_message_get_all_recipients(), so I think to:charles will find the +original message. + +Side note #2, I think we should provide *all* versions of reply-headers +(reply-to-sender, reply-to-all, mail-followup-to, whatnot) in the +formatted output, and let the user toggle between them in notmuch-emacs +while composing the reply. + +BR, +Jani. -- 2.26.2