From bf24e46b13bb21dc7372324663df52958f687430 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 19 Jun 2016 23:15:32 +0300 Subject: [PATCH] [RFC PATCH 4/6] cli/reply: pass internet address list to munge detect --- be/8039ba277e0d161cc084fc47a059eacfadf9a5 | 141 ++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 be/8039ba277e0d161cc084fc47a059eacfadf9a5 diff --git a/be/8039ba277e0d161cc084fc47a059eacfadf9a5 b/be/8039ba277e0d161cc084fc47a059eacfadf9a5 new file mode 100644 index 000000000..879d1e3ec --- /dev/null +++ b/be/8039ba277e0d161cc084fc47a059eacfadf9a5 @@ -0,0 +1,141 @@ +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 790156DE092A + for ; Sun, 19 Jun 2016 13:17:26 -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.445 +X-Spam-Level: +X-Spam-Status: No, score=0.445 tagged_above=-999 required=5 tests=[AWL=1.165, + 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 m21nsBap1Px2 for ; + Sun, 19 Jun 2016 13:17:18 -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 311DD6DE0350 for + ; Sun, 19 Jun 2016 13:17:08 -0700 (PDT) +Received: by mail-wm0-f66.google.com with SMTP id a66so4470142wme.2 + for ; Sun, 19 Jun 2016 13:17:08 -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=FgEWcwZwZNHGDLoYAMew8rAbVt2GXziMhF5ZA3VKnBg=; + b=Nxr+Z7rc10zPp6kKGSecuVO0S+fTlEtNag8ID1jimYvyGr8YndhdlDkY5u7snA2tPb + r6hGkLFLO5vaYKBrsUw9JPh1MhZaVD7b6JKubnCG5BRL6zZ7ddXlMlayxgBXY0UaLQv8 + /nT+BFFFSAN4muEo008og0A1mz8S5PgQJGlaA2+LQlHDvGIkKcl7DyyDvNZSwSGVIRH7 + qb2JECyQt+vQ+DNtJQ/D/mSVvJvoW3VD3eJDWEfLNPIMm2lEoXFMkHvvO9pm1KRY7TzL + +VNdFVGmjrhIbKyxlrjjG/S/FdU3rGsXeJqcJxb+1doxerl05QDfJ6mEOLhyytvUuX9l + D6ow== +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=FgEWcwZwZNHGDLoYAMew8rAbVt2GXziMhF5ZA3VKnBg=; + b=Qj4GrQUhKHQGZ7wsdMsNXu8gh4OjlMLCCmgEEepUhNwjypuebNLF7aRkQOoWvneWOQ + fVtURdPLtHCQ99vpEKxXkV9XHp/n/jlIZ3iLS2GT3J6JzuqovnVZ24FbDDpTK4BO7X4g + eL6vtw7iSKNgbWR0ykIcUWD8S3bsI8T5O6YuOowlB4raYrPBTSnHmEDU1rwRtu0N4ASE + lOrfCDyRoe0nLN4P5T6uP2/lo/Sg26mRUVwVCr8IvrYYflD+/Lzmm4p2cagST2rHTjON + II891P6OdC1VoWiRz31H31hTYHNVJVe9n+nU2Qqd+FZrlDANo13mzqwKSiMVORNNeYTx + iSlQ== +X-Gm-Message-State: + ALyK8tKhA3R2w7aI0fmLOHyxsBwEVtwKn4e4q6AXprQZohtobiMdgHbT09UjPscy7EszSA== +X-Received: by 10.194.158.138 with SMTP id wu10mr10673642wjb.84.1466367426806; + Sun, 19 Jun 2016 13:17:06 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw2-58c37a-44.dhcp.inet.fi. + [88.195.122.44]) + by smtp.gmail.com with ESMTPSA id bb4sm20457234wjb.32.2016.06.19.13.17.05 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 19 Jun 2016 13:17:06 -0700 (PDT) +From: Jani Nikula +To: Jani Nikula , + notmuch@notmuchmail.org +Cc: Daniel Kahn Gillmor +Subject: [RFC PATCH 4/6] cli/reply: pass internet address list to munge detect +Date: Sun, 19 Jun 2016 23:15:32 +0300 +Message-Id: + <723de0c9331d8c96be4ea4b16fdb85095c9defd1.1466366738.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: Sun, 19 Jun 2016 20:17:26 -0000 + +--- + notmuch-reply.c | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/notmuch-reply.c b/notmuch-reply.c +index 98034485c546..cf4248bd6794 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -231,19 +231,18 @@ scan_address_list (InternetAddressList *list, + * in either the 'To' or 'Cc' header of the message? + */ + static int +-reply_to_header_is_redundant (notmuch_message_t *message, const char *reply_to) ++reply_to_header_is_redundant (notmuch_message_t *message, ++ InternetAddressList *reply_to_list) + { + const char *to, *cc, *addr; +- InternetAddressList *list; + InternetAddress *address; + InternetAddressMailbox *mailbox; + +- list = internet_address_list_parse_string (reply_to); +- +- if (internet_address_list_length (list) != 1) ++ if (reply_to_list == NULL || ++ internet_address_list_length (reply_to_list) != 1) + return 0; + +- address = internet_address_list_get_address (list, 0); ++ address = internet_address_list_get_address (reply_to_list, 0); + if (INTERNET_ADDRESS_IS_GROUP (address)) + return 0; + +@@ -269,6 +268,8 @@ static InternetAddressList *get_sender(notmuch_message_t *message, + + reply_to = g_mime_message_get_reply_to (mime_message); + if (reply_to && *reply_to) { ++ InternetAddressList *reply_to_list; ++ + /* + * Some mailing lists munge the Reply-To header despite it + * being A Bad Thing, see +@@ -282,8 +283,11 @@ static InternetAddressList *get_sender(notmuch_message_t *message, + * to the list. Note that the address in the Reply-To header + * will always appear in the reply if reply_all is true. + */ +- if (! reply_to_header_is_redundant (message, reply_to)) +- return internet_address_list_parse_string (reply_to); ++ reply_to_list = internet_address_list_parse_string (reply_to); ++ if (! reply_to_header_is_redundant (message, reply_to_list)) ++ return reply_to_list; ++ ++ g_object_unref (G_OBJECT (reply_to_list)); + } + + return internet_address_list_parse_string ( +-- +2.1.4 + -- 2.26.2