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 woUZLPXY3mAtxAAAgWs5BA (envelope-from ) for ; Fri, 02 Jul 2021 11:14:29 +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 GPlOJ/XY3mBmIwAAB5/wlQ (envelope-from ) for ; Fri, 02 Jul 2021 09:14:29 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 143A9235BF for ; Fri, 2 Jul 2021 11:14:29 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7777D290A9; Fri, 2 Jul 2021 05:14:26 -0400 (EDT) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by mail.notmuchmail.org (Postfix) with ESMTPS id 35E4B290A4 for ; Fri, 2 Jul 2021 05:14:24 -0400 (EDT) Received: by mail-lj1-f180.google.com with SMTP id f13so12382554ljp.10 for ; Fri, 02 Jul 2021 02:14:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LHwrQDwwtV8FWPLLHQI8QkyqykwGhXDJ7ifYoEZN/CI=; b=G4BhmKEQ4tHfG50T27nghhEmjGAmmX4GRreg6kPxUk+6AfyC6iy8IprUSGL7ASy+2l YBNvICKRi1qMYwfp9FK6OKZZdfiKicFVn/RcW8kTr6CSROkYSfGNrZCHtYpl2cqf9cMT /xrz4BwC5b3SALKAFmItjMiGBoyx4RLzi8CjTcnDtTYT7/BkuMj99m2PcmazkqgT7jbn 4udpurb9Uf+lJKyYJwTp5sSDvioVUSU2i9Eq3xoOjoSvVcCC3QKBRPQDHao2He7N5twB GjmQtDXGIXoHuICFFpiUdznVX4fXrJyHxL7gP/66FnahMvjLsY1GimvlfM36+bDomvlI 4bfg== X-Gm-Message-State: AOAM530pcxZRdK2+CnAqY+Dke1K8xHEYNfQv6y3klSOxUuwKJeKwFoIh arFzH9E3ue6UlIUERasoctB+kQMBFMLKOA== X-Google-Smtp-Source: ABdhPJziniTebnI5ndrOaVZCOaVRnmqn8BJ7kl3lLDjmv82JDURyRaGEbclIWAcJ77zo+Vs8zKY5QQ== X-Received: by 2002:a2e:960e:: with SMTP id v14mr3096814ljh.148.1625217262779; Fri, 02 Jul 2021 02:14:22 -0700 (PDT) Received: from localhost (88-112-11-80.elisa-laajakaista.fi. [88.112.11.80]) by smtp.gmail.com with ESMTPSA id m16sm223699lfl.300.2021.07.02.02.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 02:14:22 -0700 (PDT) From: Hannu Hartikainen To: notmuch@notmuchmail.org Subject: [PATCH v2 2/2] lib: consider all instances of Delivered-To header Date: Fri, 2 Jul 2021 12:13:09 +0300 Message-Id: <20210702091309.26970-2-hannu@hrtk.in> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210702091309.26970-1-hannu@hrtk.in> References: <874kdkzfxk.fsf@tethera.net> <20210702091309.26970-1-hannu@hrtk.in> MIME-Version: 1.0 Message-ID-Hash: DK77F3UMUOGNR4EPIPYHY3Q2REFEW63E X-Message-ID-Hash: DK77F3UMUOGNR4EPIPYHY3Q2REFEW63E X-MailFrom: hannu.hartikainen@gmail.com 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=1625217269; 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=J90bBsMecLksaDEJXTUvGjIVOZC1vzQ5NEdIh/1K9Ow=; b=XoA6mEGc+4LYJ6GwYh3WIExmNE5UfjtlImCdunT3Uco7iy4OqUjgwV3EqDJL7poOl/fYik 2zFB63RRy+G0aHOtaxDBsvCPdK2hL/rJejVyflyw52c+dGPg8PaPcgLSidqq03E8MkIM1Y bwttRu9ZPvE7gRu0tumKNQSwOrfrYr1h84vJ7PmHI+Cv1g+JfR1b1Cia8VeCmnfRasLK4j 5BDJPuOmC5PLLejAYqY5SgNw25C2dWwzTxAa60XMdXUZkUarw2dmniUS/GrUSk+e6WU2mr BgHbqWfmCMZQgxDK645lq9+GbFnM1ylB5SyaoPRAddZ+J7iogeprtZyGmU1/sg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625217269; a=rsa-sha256; cv=none; b=mQWDniLYp5s3iaz7fzVM52x7WYfXYdjOvTnUumXVPJi2REEb9fcAh/gsR1Lj0//4ahJ9wg 6FDZsEnsjwsRUMm15HcZbpMLNiPvf2V2qd5+LrVS55+6eQkR09FfQJGVWu1NO5aVPpDz9D 5x4qFVYprsgV3IUT4jDqaLAo3gDUlrOnOZ+tutV8NH4lfNUsD6lRoV5HNPFsEd3FfYznNE IX4488R5NwZGjuAlmCpNSWlF0Uti9WuCAacQXY6Nn+5FSP4Y63Lx/97ooYi6a//57Ma0ZS E9lQx7MXVS/UqP3v5/tG6C4/H+KpSjmJt1DA8w6yb90eofmqacX2bFmVU2t8Ew== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.05 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 143A9235BF X-Spam-Score: -1.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: Wz1R6AbY+Osk 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. --- lib/message-file.c | 13 +++++++++---- notmuch-reply.c | 7 +++++-- test/T220-reply.sh | 1 - 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/message-file.c b/lib/message-file.c index 647ccf3a..68f646a4 100644 --- a/lib/message-file.c +++ b/lib/message-file.c @@ -291,11 +291,16 @@ _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) { /* - * 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 (eg. + * primary_email before other_email). */ decoded = _notmuch_message_file_get_combined_header (message, header); } else { diff --git a/notmuch-reply.c b/notmuch-reply.c index 08140799..ebb621e0 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -464,8 +464,8 @@ guess_from_in_received_by (notmuch_database_t *notmuch, const char *received) * (last Received: header added) and try to extract from them * indications to which email address this message was delivered. * - * The Received: header is special in our get_header function and is - * always concatenated. + * The Received: header is among special ones in our get_header function + * and is always concatenated. * * Return the address that was found, if any, and NULL otherwise. */ @@ -499,6 +499,9 @@ guess_from_in_received_headers (notmuch_message_t *message) * headers: Envelope-To, X-Original-To, and Delivered-To (searched in * that order). * + * The Delivered-To: header is among special ones in our get_header + * function and is always concatenated. + * * Return the address that was found, if any, and NULL otherwise. */ static const char * diff --git a/test/T220-reply.sh b/test/T220-reply.sh index 9f711a04..2db36fef 100755 --- a/test/T220-reply.sh +++ b/test/T220-reply.sh @@ -246,7 +246,6 @@ On Tue, 05 Jan 2010 15:43:56 -0000, Sender wrote: OK" test_begin_subtest "From guessing: multiple Delivered-To" -test_subtest_known_broken add_message '[from]="Sender "' \ '[to]="Recipient "' \ '[subject]="From guessing"' \ -- 2.32.0