[PATCH] cli: sanitize the received header before scanning for replies
authorJani Nikula <jani@nikula.org>
Wed, 19 Mar 2014 16:44:50 +0000 (18:44 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:00:49 +0000 (10:00 -0800)
2d/d36e1a9dd07e77f9fdc7b8738c7c1470261d96 [new file with mode: 0644]

diff --git a/2d/d36e1a9dd07e77f9fdc7b8738c7c1470261d96 b/2d/d36e1a9dd07e77f9fdc7b8738c7c1470261d96
new file mode 100644 (file)
index 0000000..157077a
--- /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 17171431FBF\r
+       for <notmuch@notmuchmail.org>; Wed, 19 Mar 2014 09:45:01 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 CaPaXe5veKzP for <notmuch@notmuchmail.org>;\r
+       Wed, 19 Mar 2014 09:44:57 -0700 (PDT)\r
+Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com\r
+ [74.125.83.52])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 5569F431FAF   for <notmuch@notmuchmail.org>; Wed, 19 Mar 2014 09:44:57 -0700\r
+ (PDT)\r
+Received: by mail-ee0-f52.google.com with SMTP id e49so6697150eek.25\r
+       for <notmuch@notmuchmail.org>; Wed, 19 Mar 2014 09:44:54 -0700 (PDT)\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;\r
+       bh=ZYgk1N422FXITOqmN3nTfM0xuLEGfgXh8q/J5SJSxv8=;\r
+       b=W/DG0MUAtVNxLcj0s2Fa0A4wRCi2VwVTSzoWZPr/f9JhOGJfL+dr3vz/8gxSTnRLte\r
+       7IrM+r48EupwFcGMrbCiQ3gnQKX6VyUpW9qa98Y7gfUZ0Dkc51PwSPLizncuTR/0duXZ\r
+       A+02lqsgDMqXb4GTCOeF/ITIloioaHaA+2BgUTrvJifk2nEd2O7I5l4TyJGWjdJqdMXs\r
+       ACPPF/AGnONtPxARgm7JSjf8+QT8aI93PGv3zI/hxPMjxz6KBe/hCyYKxofLD96De+Rd\r
+       DzV0UiS5RtPcG2eXYAMmz9jeD6H2INvTD9LmrSA4XhPJDtqx9if1pBo58rad7aLg4DL/\r
+       LfkQ==\r
+X-Gm-Message-State:\r
+ ALoCoQl0lvbhG9to0H2RP3NbxM3ROy0GZVh6VpJRKcz4lK3/873XDoJtugtPTjA/D6kfIYlNrh3f\r
+X-Received: by 10.14.105.4 with SMTP id j4mr23533068eeg.41.1395247494668;\r
+       Wed, 19 Mar 2014 09:44:54 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91])\r
+       by mx.google.com with ESMTPSA id n5sm5208328eex.14.2014.03.19.09.44.52\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Wed, 19 Mar 2014 09:44:53 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] cli: sanitize the received header before scanning for replies\r
+Date: Wed, 19 Mar 2014 18:44:50 +0200\r
+Message-Id: <1395247490-19892-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.9.0\r
+In-Reply-To: <20140203204611.GL4375@mit.edu>\r
+References: <20140203204611.GL4375@mit.edu>\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: Wed, 19 Mar 2014 16:45:01 -0000\r
+\r
+This makes the from guessing agnostic to header folding by spaces or\r
+tabs.\r
+\r
+---\r
+\r
+I haven't had the time to update the rest of the series, but get the\r
+prep patch out of the way.\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 47993d223090..7c1c80959ed6 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 (NULL, 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.9.0\r
+\r