[PATCH v3 4/6] cli: sanitize the received header before scanning for replies
authorJani Nikula <jani@nikula.org>
Mon, 3 Feb 2014 19:51:44 +0000 (21:51 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:39 +0000 (09:59 -0800)
3b/26e8cc51fa833452dd4b2bc21c6c15443de168 [new file with mode: 0644]

diff --git a/3b/26e8cc51fa833452dd4b2bc21c6c15443de168 b/3b/26e8cc51fa833452dd4b2bc21c6c15443de168
new file mode 100644 (file)
index 0000000..2466b7f
--- /dev/null
@@ -0,0 +1,116 @@
+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 olra.theworths.org (Postfix) with ESMTP id 2A2A1431FBC\r
+       for <notmuch@notmuchmail.org>; Mon,  3 Feb 2014 11:52:44 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id EungCdJOoANT for <notmuch@notmuchmail.org>;\r
+       Mon,  3 Feb 2014 11:52:40 -0800 (PST)\r
+Received: from mail-ee0-f47.google.com (mail-ee0-f47.google.com\r
+ [74.125.83.47])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ D6195431FAF   for <notmuch@notmuchmail.org>; Mon,  3 Feb 2014 11:52:09 -0800\r
+ (PST)\r
+Received: by mail-ee0-f47.google.com with SMTP id d49so3828953eek.20\r
+       for <notmuch@notmuchmail.org>; Mon, 03 Feb 2014 11:52:08 -0800 (PST)\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=JKL4q0NcwwMW+X4vuzPJGyeaaLNVo8HvF2YsNXxwPfo=;\r
+       b=CkK/AKGJvLOCLIDu6eHMUe8K+YIzC2e0NoBRdfdy5bceqdUYp6vMa6hgSIlp0caeA6\r
+       KBPYZLVdtoaFNy9RsQFthcYU5izSxrIueCB10LZqjHpy/JQjT+H41EqfW2QEZUnVqPTF\r
+       FZC0pMBb/JdPTk9IY6ptkDoJFHGexYQNOpLmK+aROT2rBlXiYAggjX8WKkIqp1X0N189\r
+       wDfs4Vh2z6mK+THIHCOLePrxS2Ej50VwWuQ9ate129iMtbSM91lP4A025FHqGRyMRgBm\r
+       zKgwelsOfe/y2ZCYK3IF204juOwsWzBuKH5hTv8B/f22ZyLpewCq77XRmNYeEZZMxU3O\r
+       wx5w==\r
+X-Gm-Message-State:\r
+ ALoCoQll34WFVhBR1S/vKdrf3GkdqyN5CZJUetKRPjQe+1O5bODGTA02z1jaAwg+2gD7Qda9DDh5\r
+X-Received: by 10.15.61.7 with SMTP id h7mr10466550eex.49.1391457128563;\r
+       Mon, 03 Feb 2014 11:52:08 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91])\r
+       by mx.google.com with ESMTPSA id m1sm78836622een.7.2014.02.03.11.52.06\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Mon, 03 Feb 2014 11:52:07 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 4/6] cli: sanitize the received header before scanning for\r
+       replies\r
+Date: Mon,  3 Feb 2014 21:51:44 +0200\r
+Message-Id:\r
+ <df154611af9e23ef443f56c5abb90c8b276b18e7.1391456555.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.5.2\r
+In-Reply-To: <cover.1391456555.git.jani@nikula.org>\r
+References: <cover.1391456555.git.jani@nikula.org>\r
+In-Reply-To: <cover.1391456555.git.jani@nikula.org>\r
+References: <cover.1391456555.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 03 Feb 2014 19:52:44 -0000\r
+\r
+This makes the from guessing agnostic to header folding by spaces or\r
+tabs.\r
+---\r
+ notmuch-reply.c | 12 ++++++++++--\r
+ 1 file changed, 10 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 47993d2..3f7021e 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -21,6 +21,7 @@\r
+  */\r
\r
+ #include "notmuch-client.h"\r
++#include "string-util.h"\r
+ #include "sprinter.h"\r
\r
+ static void\r
+@@ -465,14 +466,21 @@ guess_from_in_received_headers (notmuch_config_t *config,\r
+                               notmuch_message_t *message)\r
+ {\r
+     const char *received, *addr;\r
++    char *sanitized;\r
\r
+     received = notmuch_message_get_header (message, "received");\r
+     if (! received)\r
+       return NULL;\r
\r
+-    addr = guess_from_in_received_for (config, received);\r
++    sanitized = sanitize_string (config, received);\r
++    if (! sanitized)\r
++      return NULL;\r
++\r
++    addr = guess_from_in_received_for (config, sanitized);\r
+     if (! addr)\r
+-      addr = guess_from_in_received_by (config, received);\r
++      addr = guess_from_in_received_by (config, sanitized);\r
++\r
++    talloc_free (sanitized);\r
\r
+     return addr;\r
+ }\r
+-- \r
+1.8.5.2\r
+\r