[RFC PATCH 4/6] cli/reply: pass internet address list to munge detect
authorJani Nikula <jani@nikula.org>
Sun, 19 Jun 2016 20:15:32 +0000 (23:15 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:07 +0000 (16:22 -0700)
be/8039ba277e0d161cc084fc47a059eacfadf9a5 [new file with mode: 0644]

diff --git a/be/8039ba277e0d161cc084fc47a059eacfadf9a5 b/be/8039ba277e0d161cc084fc47a059eacfadf9a5
new file mode 100644 (file)
index 0000000..879d1e3
--- /dev/null
@@ -0,0 +1,141 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 790156DE092A\r
+ for <notmuch@notmuchmail.org>; Sun, 19 Jun 2016 13:17:26 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.445\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.445 tagged_above=-999 required=5 tests=[AWL=1.165, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id m21nsBap1Px2 for <notmuch@notmuchmail.org>;\r
+ Sun, 19 Jun 2016 13:17:18 -0700 (PDT)\r
+Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
+ [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 311DD6DE0350 for\r
+ <notmuch@notmuchmail.org>; Sun, 19 Jun 2016 13:17:08 -0700 (PDT)\r
+Received: by mail-wm0-f66.google.com with SMTP id a66so4470142wme.2\r
+ for <notmuch@notmuchmail.org>; Sun, 19 Jun 2016 13:17:08 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=nikula-org.20150623.gappssmtp.com; s=20150623;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references\r
+ :in-reply-to:references;\r
+ bh=FgEWcwZwZNHGDLoYAMew8rAbVt2GXziMhF5ZA3VKnBg=;\r
+ b=Nxr+Z7rc10zPp6kKGSecuVO0S+fTlEtNag8ID1jimYvyGr8YndhdlDkY5u7snA2tPb\r
+ r6hGkLFLO5vaYKBrsUw9JPh1MhZaVD7b6JKubnCG5BRL6zZ7ddXlMlayxgBXY0UaLQv8\r
+ /nT+BFFFSAN4muEo008og0A1mz8S5PgQJGlaA2+LQlHDvGIkKcl7DyyDvNZSwSGVIRH7\r
+ qb2JECyQt+vQ+DNtJQ/D/mSVvJvoW3VD3eJDWEfLNPIMm2lEoXFMkHvvO9pm1KRY7TzL\r
+ +VNdFVGmjrhIbKyxlrjjG/S/FdU3rGsXeJqcJxb+1doxerl05QDfJ6mEOLhyytvUuX9l\r
+ D6ow==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=FgEWcwZwZNHGDLoYAMew8rAbVt2GXziMhF5ZA3VKnBg=;\r
+ b=Qj4GrQUhKHQGZ7wsdMsNXu8gh4OjlMLCCmgEEepUhNwjypuebNLF7aRkQOoWvneWOQ\r
+ fVtURdPLtHCQ99vpEKxXkV9XHp/n/jlIZ3iLS2GT3J6JzuqovnVZ24FbDDpTK4BO7X4g\r
+ eL6vtw7iSKNgbWR0ykIcUWD8S3bsI8T5O6YuOowlB4raYrPBTSnHmEDU1rwRtu0N4ASE\r
+ lOrfCDyRoe0nLN4P5T6uP2/lo/Sg26mRUVwVCr8IvrYYflD+/Lzmm4p2cagST2rHTjON\r
+ II891P6OdC1VoWiRz31H31hTYHNVJVe9n+nU2Qqd+FZrlDANo13mzqwKSiMVORNNeYTx\r
+ iSlQ==\r
+X-Gm-Message-State:\r
+ ALyK8tKhA3R2w7aI0fmLOHyxsBwEVtwKn4e4q6AXprQZohtobiMdgHbT09UjPscy7EszSA==\r
+X-Received: by 10.194.158.138 with SMTP id wu10mr10673642wjb.84.1466367426806;\r
+  Sun, 19 Jun 2016 13:17:06 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c37a-44.dhcp.inet.fi.\r
+ [88.195.122.44])\r
+ by smtp.gmail.com with ESMTPSA id bb4sm20457234wjb.32.2016.06.19.13.17.05\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sun, 19 Jun 2016 13:17:06 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Jani Nikula <jani@nikula.org>,\r
+       notmuch@notmuchmail.org\r
+Cc: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+Subject: [RFC PATCH 4/6] cli/reply: pass internet address list to munge detect\r
+Date: Sun, 19 Jun 2016 23:15:32 +0300\r
+Message-Id:\r
+ <723de0c9331d8c96be4ea4b16fdb85095c9defd1.1466366738.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1466366737.git.jani@nikula.org>\r
+References: <cover.1466284726.git.jani@nikula.org>\r
+ <cover.1466366737.git.jani@nikula.org>\r
+In-Reply-To: <cover.1466366737.git.jani@nikula.org>\r
+References: <cover.1466366737.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 19 Jun 2016 20:17:26 -0000\r
+\r
+---\r
+ notmuch-reply.c | 20 ++++++++++++--------\r
+ 1 file changed, 12 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 98034485c546..cf4248bd6794 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -231,19 +231,18 @@ scan_address_list (InternetAddressList *list,\r
+  * in either the 'To' or 'Cc' header of the message?\r
+  */\r
+ static int\r
+-reply_to_header_is_redundant (notmuch_message_t *message, const char *reply_to)\r
++reply_to_header_is_redundant (notmuch_message_t *message,\r
++                            InternetAddressList *reply_to_list)\r
+ {\r
+     const char *to, *cc, *addr;\r
+-    InternetAddressList *list;\r
+     InternetAddress *address;\r
+     InternetAddressMailbox *mailbox;\r
\r
+-    list = internet_address_list_parse_string (reply_to);\r
+-\r
+-    if (internet_address_list_length (list) != 1)\r
++    if (reply_to_list == NULL ||\r
++      internet_address_list_length (reply_to_list) != 1)\r
+       return 0;\r
\r
+-    address = internet_address_list_get_address (list, 0);\r
++    address = internet_address_list_get_address (reply_to_list, 0);\r
+     if (INTERNET_ADDRESS_IS_GROUP (address))\r
+       return 0;\r
\r
+@@ -269,6 +268,8 @@ static InternetAddressList *get_sender(notmuch_message_t *message,\r
\r
+     reply_to = g_mime_message_get_reply_to (mime_message);\r
+     if (reply_to && *reply_to) {\r
++      InternetAddressList *reply_to_list;\r
++\r
+         /*\r
+        * Some mailing lists munge the Reply-To header despite it\r
+        * being A Bad Thing, see\r
+@@ -282,8 +283,11 @@ static InternetAddressList *get_sender(notmuch_message_t *message,\r
+        * to the list. Note that the address in the Reply-To header\r
+        * will always appear in the reply if reply_all is true.\r
+        */\r
+-      if (! reply_to_header_is_redundant (message, reply_to))\r
+-          return internet_address_list_parse_string (reply_to);\r
++      reply_to_list = internet_address_list_parse_string (reply_to);\r
++      if (! reply_to_header_is_redundant (message, reply_to_list))\r
++          return reply_to_list;\r
++\r
++      g_object_unref (G_OBJECT (reply_to_list));\r
+     }\r
\r
+     return internet_address_list_parse_string (\r
+-- \r
+2.1.4\r
+\r