[PATCH v2 4/7] cli: sanitize the received header before scanning for replies
authorJani Nikula <jani@nikula.org>
Sat, 30 Nov 2013 15:33:53 +0000 (17:33 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:58:32 +0000 (09:58 -0800)
2f/bc4f504a95053907711c3c5ba2e79f8bb4ef4c [new file with mode: 0644]

diff --git a/2f/bc4f504a95053907711c3c5ba2e79f8bb4ef4c b/2f/bc4f504a95053907711c3c5ba2e79f8bb4ef4c
new file mode 100644 (file)
index 0000000..792229a
--- /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 C57FB429E32\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:20 -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 mnPx0zkDrq1r for <notmuch@notmuchmail.org>;\r
+       Sat, 30 Nov 2013 07:34:16 -0800 (PST)\r
+Received: from mail-ea0-f170.google.com (mail-ea0-f170.google.com\r
+       [209.85.215.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id CB6C4431FAF\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:10 -0800 (PST)\r
+Received: by mail-ea0-f170.google.com with SMTP id k10so7669523eaj.15\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:09 -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=RNKsLiEBOBVvW/FxB7Xzhr3InvqwtkWWlgENy/Ffikk=;\r
+       b=a4RZEedWI3TTf2Joo2PxQjH2IoyV6RXO54jSfW3FUzbMyYuKCRTKmA0vh8D9ggfUGl\r
+       XZZZLU5mugza5D/eTS15SG+JeXpBuOYqkxE1QqiIEZBW00nlqZN+DurX5Qac1j6d4/dL\r
+       H9e5cRr49GeZuh11TrskFZNiTw3Z57FldiJCkPyNgQYoEiF1KEbkmFz5RSSxo0FhUhmm\r
+       nCQQ62ir8WvIubwmbVTYlPdu/9l5Smx9xx3RFdyc2EXFAFCP6gQxcSyapaagngoJazNd\r
+       6QCkLMkCtKBCsBuwEP6ZBiZwGxVndGE8AHOWrRD522AeVXzHgbjwSzYn6jjduFoAEQ6B\r
+       iSJw==\r
+X-Gm-Message-State:\r
+ ALoCoQkp9lK89mdR14nnpjgZq2Q6iKZCQ9/OY+Bh70KS3wvJNtThtJ8WZVlSrtzRGu9NNNkCZtTZ\r
+X-Received: by 10.14.22.68 with SMTP id s44mr57829545ees.16.1385825649736;\r
+       Sat, 30 Nov 2013 07:34:09 -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 g7sm3264411eet.12.2013.11.30.07.34.08\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sat, 30 Nov 2013 07:34:09 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 4/7] cli: sanitize the received header before scanning for\r
+       replies\r
+Date: Sat, 30 Nov 2013 17:33:53 +0200\r
+Message-Id:\r
+ <90e472ab54b58786c2462ae3656aafdc27d10ca5.1385825425.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.4.2\r
+In-Reply-To: <cover.1385825425.git.jani@nikula.org>\r
+References: <cover.1385825425.git.jani@nikula.org>\r
+In-Reply-To: <cover.1385825425.git.jani@nikula.org>\r
+References: <cover.1385825425.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: Sat, 30 Nov 2013 15:34:21 -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 ca41405..a2eee17 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
+@@ -463,14 +464,21 @@ guess_from_received_header (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_received_for (config, received);\r
++    sanitized = sanitize_string (config, received);\r
++    if (! sanitized)\r
++      return NULL;\r
++\r
++    addr = guess_from_received_for (config, sanitized);\r
+     if (! addr)\r
+-      addr = guess_from_received_by (config, received);\r
++      addr = guess_from_received_by (config, sanitized);\r
++\r
++    talloc_free (sanitized);\r
\r
+     return addr;\r
+ }\r
+-- \r
+1.8.4.2\r
+\r