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 4603E6DE092F for ; Sun, 19 Jun 2016 13:17:29 -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.568 X-Spam-Level: X-Spam-Status: No, score=-0.568 tagged_above=-999 required=5 tests=[AWL=0.152, 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 CvuAhonsk-JN for ; Sun, 19 Jun 2016 13:17:20 -0700 (PDT) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 98AD86DE0352 for ; Sun, 19 Jun 2016 13:17:09 -0700 (PDT) Received: by mail-wm0-f66.google.com with SMTP id a66so4470244wme.2 for ; Sun, 19 Jun 2016 13:17:09 -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=JbNUhTkfYGeVGMQbfELh7g4/EzRbs31Oukows4w45v3VlQ4ju7jMDqRIs0junNNMk1 HPuGmSDL8w9KSYYMMMS1leHOqvJthLngLvi65xwZosfVhAP46O2J7PPDuZ1sf4i7lb8Z st47H/eH3rIhlWdeYAADg1YCEq085YYfA+ovwknme5Fpvq5GypeGGzwsZvTzUyyyNN+N HAxy74nozcNSJVliuX9hMY29BvpUrqCcoL0k/u8lQJnkEMhqez8SSVNoVmqb19S43aGI tFo0YIAkRcRbNoOp7i4yBckDhJ1sENttDTr5iuZ+PyhfPe8BmQQKKibl2ke5hlcjT2rg dMBA== 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=cQdpNNwWoNDrjNqIjjIgecQxrqmQQJ0ysQhfZkXW9eUfjlP0tSYMl/7BSkwhxAxVnr 7XOeRmbzFuG8MiPjL84Kch1NJDw+YNEZxeTndOnwO7mcKwNk7GCO3Blc0cLgA5bdZfjg FbwmphqoClWDJeWxrYNz5B90o6Z/JR5CwRR/EBPuwxuZRI3c+B25ytW3rlXMKcdL1sNq tBSRkd8oQHK2h4DxeSco5i0nD5+tWZPyMgS+rhBDRsWbFEcnGc7fijBTHMSXQl7TQApo 7XKMxVZfh05iBa5PBEUuivjiN2vKjAVwYA0B+yI88nTYrc8vKUbETRXkmuRktYqH+Rit 3YgQ== X-Gm-Message-State: ALyK8tJ0B86gOR7Mxla6JXdfWYD6O4IWJq9lMHnpY3sDqoIURbOnTzHASPuJ09aOVW6sMg== X-Received: by 10.194.104.40 with SMTP id gb8mr12503228wjb.146.1466367428318; Sun, 19 Jun 2016 13:17:08 -0700 (PDT) Received: from localhost (mobile-access-bcee4e-81.dhcp.inet.fi. [188.238.78.81]) by smtp.gmail.com with ESMTPSA id zg10sm35591520wjb.1.2016.06.19.13.17.07 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 19 Jun 2016 13:17:07 -0700 (PDT) From: Jani Nikula To: Jani Nikula , notmuch@notmuchmail.org Cc: Daniel Kahn Gillmor Subject: [RFC PATCH 5/6] cli/reply: pass gmime message to munge detection Date: Sun, 19 Jun 2016 23:15:33 +0300 Message-Id: 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: Sun, 19 Jun 2016 20:17:29 -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