From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +P2tCKBl12BMagAAgWs5BA (envelope-from ) for ; Sat, 26 Jun 2021 19:36:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GLzIA6Bl12DLTgAAB5/wlQ (envelope-from ) for ; Sat, 26 Jun 2021 17:36:32 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5E6281BCA9 for ; Sat, 26 Jun 2021 19:36:31 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 1075D290C4; Sat, 26 Jun 2021 13:36:27 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 9985027E2B for ; Sat, 26 Jun 2021 13:36:24 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 6090C5FD21; Sat, 26 Jun 2021 13:36:24 -0400 (EDT) Received: (nullmailer pid 254438 invoked by uid 1000); Sat, 26 Jun 2021 17:36:23 -0000 From: David Bremner To: Hannu Hartikainen , notmuch@notmuchmail.org Subject: Re: [PATCH] lib: consider all instances of Delivered-To header In-Reply-To: <20210623102906.20602-1-hannu@hrtk.in> References: <20210623102906.20602-1-hannu@hrtk.in> Date: Sat, 26 Jun 2021 14:36:23 -0300 Message-ID: <874kdkzfxk.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: AV62YIGM5FZW723JS7IEZRLRLTIYA7FX X-Message-ID-Hash: AV62YIGM5FZW723JS7IEZRLRLTIYA7FX X-MailFrom: david@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Hannu Hartikainen X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624728991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mQGi13b4408mR+AFtLcvmPAYlrYKCbe8uPqNd7sNpMQ=; b=MHCbDDF34EVouOExmIFhNIJUN1GRS1gRehfjEUI5JwyDwxijk1TRGxWAm9SR1gXvFIv7jT rB1OMjIu4eo9LKg45Y4bgNbhlnHAgztZ6bjJ+oHuKjQp8+vAeIT5cT1xjjIUGNZypm/nEB xudDf0r9QTy/HqbdirlvvOkYaj8UiNUGMQ+qfOALwcfx0wYl3lna6x5UOauR3m9X4r33sX B03eIoH4r1OmtlG2WAEfQyIkxeIOu3WweGYlzhKCfRktaSOt/ectcdDmc9HAVy8uDKkYul Z/3TJkZXI0ACdNoZGJ3Gn+RJEc6SvMmDuHNbmp78xC0BMYfFz89sR4Bxmf8guA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624728991; a=rsa-sha256; cv=none; b=eUfMpDRazq7GIRsH+LfugfQ5ZRLHktnvVOvVj8JK3kehujrUEqSKTsHEpuwfE76MLYs8XJ WCxSSNI73/zMfpcCWfsfbyAEKFSWYPkEhKsDObgKib/b5QO0KKlUQxGUBONy16VUQoRSI5 XjpS0kTwvzrA+EjCy2EcEF9sGkSl0P5P19SlkNgoSO3WMdgEaFQrwXZsGYJ0yDXJfyJ5uw TuqOmjDqVlQjxJOEs8VH+X1kjefpj3TWlTKP/dr4L6HAIOL2RLsZ/LEjE07GoMY4hnWn4M L1xbuf/lQWVjZ7lVeUJYVTNB+jhU1/GpKsjIp6PDRLukvbTqP/CjOJ3SzPx1wg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -2.01 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 5E6281BCA9 X-Spam-Score: -2.01 X-Migadu-Scanner: scn1.migadu.com X-TUID: yhqn8TctwToy Hannu Hartikainen writes: > When using notmuch-reply and guessing the From: address from > Delivered-To headers, I had the wrong address chosen today. This was > because the messages from the notmuch list contain these headers in this > order: > > Delivered-To: hannu.hartikainen@gmail.com > ... > Delivered-To: hannu@hrtk.in > > In my .notmuch-config I have the following configuration: > > primary_email=hannu@hrtk.in > other_email=hannu.hartikainen@gmail.com;... > > Before this change, notmuch-reply would guess From: @gmail.com because > that is the first Delivered-To header present. After the change, the > primary address is chosen as I would expect. > --- Delivered-to seems to be a dark corner of (non)-standardization, but it does seem that multiple deliver-to headers are relatively common and more or less make sense: https://datatracker.ietf.org/doc/draft-crocker-email-deliveredto/ > lib/message-file.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/lib/message-file.c b/lib/message-file.c > index 647ccf3a..7e8ea09c 100644 > --- a/lib/message-file.c > +++ b/lib/message-file.c > @@ -291,11 +291,15 @@ _notmuch_message_file_get_header (notmuch_message_file_t *message, > if (value) > return value; > > - if (strcasecmp (header, "received") == 0) { > + if (strcasecmp (header, "received") == 0 || > + strcasecmp (header, "delivered-to") == 0) { uncrustify suggests the following indentation change - strcasecmp (header, "delivered-to") == 0) { + strcasecmp (header, "delivered-to") == 0) { > /* > - * The Received: header is special. We concatenate all > - * instances of the header as we use this when analyzing the > - * path the mail has taken from sender to recipient. > + * The Received: header is special. We concatenate all instances of the > + * header as we use this when analyzing the path the mail has taken > + * from sender to recipient. > + * > + * Similarly, multiple instances of Delivered-To may be present. We > + * concatenate them so the one with highest priority may be picked. > */ Highest priority seems a bit vague here. Do you mean most recent? It seems like the commentary in notmuch-reply should also be updated since it claims received header is special in being concatenated I would like to see a new test here, especially since the fix is far from the effect. The following change is enough to trigger the problem you had diff --git a/test/T220-reply.sh b/test/T220-reply.sh index b6d8f42a..0d245497 100755 --- a/test/T220-reply.sh +++ b/test/T220-reply.sh @@ -232,7 +232,8 @@ add_message '[from]="Sender "' \ '[subject]="From guessing"' \ '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \ '[body]="From guessing"' \ - '[header]="Delivered-To: test_suite_other@notmuchmail.org"' + '[header]="Delivered-To: test_suite_other2@notmuchmail.org +Delivered-To: test_suite_other@notmuchmail.org"' OTOH, it probably makes sense to test the case of multiple Delivered-to headers seperately. The idiomatic (for notmuch) thing to do for a bug fix is first to add a test with "test_subtest_known_broken", then to remove that line in the commit you fix the bug. d