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 4B8216DE3B39 for ; Sat, 13 Aug 2016 04:41:35 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.575 X-Spam-Level: X-Spam-Status: No, score=-0.575 tagged_above=-999 required=5 tests=[AWL=0.145, 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 BzeVEKQ5tz-Z for ; Sat, 13 Aug 2016 04:41:27 -0700 (PDT) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id 1A3BD6DE38C5 for ; Sat, 13 Aug 2016 04:39:23 -0700 (PDT) Received: by mail-wm0-f67.google.com with SMTP id q128so2021557wma.1 for ; Sat, 13 Aug 2016 04:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=EBSFEIre9w10UPwn/U5SUVD/q7bQedUt80//bcDsm5Y=; b=qO9ETH3LVndM85clLdz9rmvEOeLDG7LqSCxrX/ToSsdNZn3MCG8GHqG9Xj62TSVCHC vfW6025FlYEN5WrSvBDg96csBlKGR/MgBNWL6bStx9AIzPq4w4qI1fRk/k8FPq533fon J/vkJ0quNIItXBtwUGw7IhZRPf0N/WADm1GL2jhAfNpuCPjQbRstHof7hq7n+Avxf1VV Vt2ax3unPk4OI6bYVS6vcyFR46gsmgXfRUqlhPTxazlbf796DbGzEa5/x4s8U/KH6m75 qDGCe68h46chvU6rdu6j3J6Zj1ZpjuuhRdEITzWeoO51n2fKthYyYWGJmHC3GXcq0ZHe Yrlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=EBSFEIre9w10UPwn/U5SUVD/q7bQedUt80//bcDsm5Y=; b=JFYhBydoVvaK16EdznIacVDwfMZ6CC0I4QZ3yUgaYULQfx9u2QTM9x+3mvLwkaGaRs IFU4H+u76P9Dh1S1c+6TW5NJ9m4sAVUgC1W2xGdTNjdx0h98xCe6tCgfrtkl6unyCp6H 0/D9y1czUaRsuBqRgjS8UO0khgI65S6erTbrn8Ilgl5pAryi3R6aRN1wg5vHYDMTczw3 OoPjUdhIn2PRab3H2YRZlMmzxnePlSTaADJk/WFWvBA+nUjVpZK3b/7D1CXiUfmZ9FUX HSnkAvDdjnoDj4YQ5A+Igjbu8uU4iNoYdJk0vK02aLG+5mYwMWLsdJNFundBA7A0rDpf 0n1Q== X-Gm-Message-State: AEkoouuUXtva8gF6hr3DqvWzq+UGv1jb1fSY3L9WRAavQSdbSpdZFAlTvIKPAArmTEEaqw== X-Received: by 10.28.148.21 with SMTP id w21mr3739056wmd.50.1471088361726; Sat, 13 Aug 2016 04:39:21 -0700 (PDT) Received: from localhost (mobile-access-bcee63-250.dhcp.inet.fi. [188.238.99.250]) by smtp.gmail.com with ESMTPSA id e10sm11794272wjc.21.2016.08.13.04.39.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Aug 2016 04:39:21 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Cc: Daniel Kahn Gillmor , jani@nikula.org Subject: [PATCH v2 13/14] cli/reply: pass gmime message to munge detection Date: Sat, 13 Aug 2016 14:37:37 +0300 Message-Id: <771c4118ad840f9b9af1a3744d53e7ede3bd837d.1471088022.git.jani@nikula.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: 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: Sat, 13 Aug 2016 11:41:35 -0000 Improves the accuracy in many ways. --- notmuch-reply.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index cf4248bd6794..abf3a6c1824c 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -230,13 +230,16 @@ scan_address_list (InternetAddressList *list, /* Does the address in the Reply-To header of 'message' already appear * in either the 'To' or 'Cc' header of the message? */ -static int -reply_to_header_is_redundant (notmuch_message_t *message, +static notmuch_bool_t +reply_to_header_is_redundant (GMimeMessage *message, InternetAddressList *reply_to_list) { - const char *to, *cc, *addr; + const char *addr, *reply_to; InternetAddress *address; InternetAddressMailbox *mailbox; + InternetAddressList *recipients; + notmuch_bool_t ret = FALSE; + int i; if (reply_to_list == NULL || internet_address_list_length (reply_to_list) != 1) @@ -247,18 +250,26 @@ reply_to_header_is_redundant (notmuch_message_t *message, return 0; mailbox = INTERNET_ADDRESS_MAILBOX (address); - addr = internet_address_mailbox_get_addr (mailbox); + reply_to = internet_address_mailbox_get_addr (mailbox); - to = notmuch_message_get_header (message, "to"); - cc = notmuch_message_get_header (message, "cc"); + recipients = g_mime_message_get_all_recipients (message); - if ((to && strstr (to, addr) != 0) || - (cc && strstr (cc, addr) != 0)) - { - return 1; + for (i = 0; i < internet_address_list_length (recipients); i++) { + address = internet_address_list_get_address (recipients, i); + if (INTERNET_ADDRESS_IS_GROUP (address)) + continue; + + mailbox = INTERNET_ADDRESS_MAILBOX (address); + addr = internet_address_mailbox_get_addr (mailbox); + if (strcmp (addr, reply_to) == 0) { + ret = TRUE; + break; + } } - return 0; + g_object_unref (G_OBJECT (recipients)); + + return ret; } static InternetAddressList *get_sender(notmuch_message_t *message, @@ -284,7 +295,7 @@ static InternetAddressList *get_sender(notmuch_message_t *message, * will always appear in the reply if reply_all is true. */ reply_to_list = internet_address_list_parse_string (reply_to); - if (! reply_to_header_is_redundant (message, reply_to_list)) + if (! reply_to_header_is_redundant (mime_message, reply_to_list)) return reply_to_list; g_object_unref (G_OBJECT (reply_to_list)); -- 2.1.4