From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2KDqGREN02BoVwEAgWs5BA (envelope-from ) for ; Wed, 23 Jun 2021 12:29:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id iOiXFREN02ABVQAA1q6Kng (envelope-from ) for ; Wed, 23 Jun 2021 10:29:37 +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 B147418720 for ; Wed, 23 Jun 2021 12:29:36 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id A819E2909E; Wed, 23 Jun 2021 06:29:30 -0400 (EDT) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by mail.notmuchmail.org (Postfix) with ESMTPS id 5D1E82908B for ; Wed, 23 Jun 2021 06:29:27 -0400 (EDT) Received: by mail-lf1-f45.google.com with SMTP id j2so3211357lfg.9 for ; Wed, 23 Jun 2021 03:29:27 -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:mime-version :content-transfer-encoding; bh=WjMWmOmonWomDeHdxAYWW+aHdbboyRN+ObuvNaZ1koI=; b=WhG6h8occMohaW2wGoVuH99iwEBPftl5NGZnSudV8C2DLiFTAUwnekfqQo2AjJafTl 07Mx4RuEuSXj7P8n2RRN+ydCtJE5mCaycvSfCEantwVbbAOPZ4djVeJY+Nt82Qmyx991 lfPErHlsskN5a7UGH9IfnNOn6O/C+MyEGW/VhnSExpOibXRSg3N5xWu6Hlu6/qskqlqM Mjf0GYP3joz6NmYHnJSINZA4EsvhdfF3TSh6DApvwhMtpzzVcQ8y7gPeYJ71yZlNyHiV FU4Oztbc5X5KXhGpDo6MH4dHnIZ8FcMC/H9w+OUWg9kvy4ETGZl4NSLusCk0ThAFYJTE FEdw== X-Gm-Message-State: AOAM530cdPBYYUQPZ+xe5A2xZOswovEfd2eIy4YldArIGpS87Dz3L+Ze eUYBfd0aAMMdJP2dKFYYV7SQgZgB+b2azA== X-Google-Smtp-Source: ABdhPJwVuurlKbtMJ0r4hzLRC+v0wdytx/4Ft8xeUxWNojqY7aKT4t7IlxZos+6I+4W8Mtig75d1Ww== X-Received: by 2002:a19:c3c2:: with SMTP id t185mr6269215lff.357.1624444165633; Wed, 23 Jun 2021 03:29:25 -0700 (PDT) Received: from localhost (88-112-11-80.elisa-laajakaista.fi. [88.112.11.80]) by smtp.gmail.com with ESMTPSA id z8sm273428ljh.120.2021.06.23.03.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 03:29:25 -0700 (PDT) From: Hannu Hartikainen To: notmuch@notmuchmail.org Subject: [PATCH] lib: consider all instances of Delivered-To header Date: Wed, 23 Jun 2021 13:29:06 +0300 Message-Id: <20210623102906.20602-1-hannu@hrtk.in> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Message-ID-Hash: ZHAN4BZH4U43LZSSBQPFQUMVEM5ATTM4 X-Message-ID-Hash: ZHAN4BZH4U43LZSSBQPFQUMVEM5ATTM4 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=1624444176; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gBPzO7f+XZleurLqbsdzrhPiwFB2u0vkBKgnzzMhEvc=; b=ON9bJKPBxSxm6RthdkagVQbONHbFjD87XtJZ7UzE0IP9SL6jd7wISST2pxSlQwiDUD35bi UWwPE0GQcDRe65s/ILGgz7fXTywD4+dlM5KH6TmIqFj4rGk8m5vGra/xLSA04q3mjEMTH/ pmstHhqbxO0yLZHfoqqCHlhJV2gnOWu3kYNPGeyk0XvoBs6ALKDRR+EgkDe8rLrPnG7IWC xTBjfD6dI5PSFzFYAeEPlPVMiZ7Zg+WAIm8lD94QBE4KMuM46SIfRKUvoSQa8nahCddWYT zb7MSuinsrKj0fYsJYU8q32autYcZ12Pv0eqQb1PID2S/uAtjhpzVnSeVRFhOw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624444176; a=rsa-sha256; cv=none; b=DtvEsxuiE0FDjsFdRo0PdlWCFKaTh9Urv+Rgn2zizcjD186/FG3nKc4zewd4vlSyItfeH4 GsBNCN9zaHPcXMjZyYIQclCz0kmpgQsJxzCt/E0NBQ51Hnnoo9DiyWUTJgQUVOssgHr2PY bkPkohJtpOmvoF+Y7iQJ2gFRu8fDemoS/lYbKr7sA6JdiknZ5e3qZTayv0aEVFZmWXs2Tz z3Ot8PFe1zF+tRSt/fHwD+tYO+GLA6RSxj2z+euNZl78llonmxvv7a/Q8QylshBfUwuPKa K/ZfrKwsOnFOdv9k70f+fAlFfjwAAbEzcwhUdiQBAAhBQMaPsJXMO8I+OkaI/Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=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.07 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: B147418720 X-Spam-Score: -1.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: GYLiWUSjPvBR 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 | 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) { /* - * 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. */ decoded = _notmuch_message_file_get_combined_header (message, header); } else { -- 2.32.0