[PATCH v2 1/7] cli: sanitize tabs and newlines to spaces in notmuch search
authorJani Nikula <jani@nikula.org>
Sat, 30 Nov 2013 15:33:50 +0000 (17:33 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:58:31 +0000 (09:58 -0800)
02/e13496e190d612cc8a8b50d70f504a39992ba5 [new file with mode: 0644]

diff --git a/02/e13496e190d612cc8a8b50d70f504a39992ba5 b/02/e13496e190d612cc8a8b50d70f504a39992ba5
new file mode 100644 (file)
index 0000000..bad54de
--- /dev/null
@@ -0,0 +1,113 @@
+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 BA7DF431FC9\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:09 -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 wNrJPPBKe5-B for <notmuch@notmuchmail.org>;\r
+       Sat, 30 Nov 2013 07:34:04 -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 12D7A431FAF\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:03 -0800 (PST)\r
+Received: by mail-ea0-f170.google.com with SMTP id k10so7790543eaj.1\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:03 -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=np75aVOqrb3NtR0M/v1YRcEvu6q3wIv4VSqv36hTOSA=;\r
+       b=ca/yn+mh3We85XXE09O+hz1piT4+YaA3eAqE1QNUsGN5iMTPc0dRGYb+j01s1wpyaz\r
+       Kp1JlXQ9o4VDdyaNdbREaddfZ4MY+HrPE5LmEtaxC4kWc7Nt4ZYNEU7DYcLB+IUlT2ja\r
+       vN0IjhfameuE44j0QqgymdZaY3/AIc/XRZVU3uXbTWwZEE5dRjt3lC4VlqSFFpR7O1RS\r
+       /Tyhl2GsckzHWN74+Qhn+yrDRUgQbOLkQjrxXwSYnKXy6RobRlEZp5bVUUzgntk+CzSS\r
+       XQB/gBcxp8Zy+W/rFtaI4NyMJHJ6qJS/S731n6jL98ay2Ivsj0Vr1WDkK5IEBHpfzMz/\r
+       AFbg==\r
+X-Gm-Message-State:\r
+ ALoCoQmcWE1KGEBRT55x5w8yTl9P0ym6bibLdK0T+QbIf7eXgVF9J9p2PB+U73B14ZMAvKmJz2Si\r
+X-Received: by 10.14.179.130 with SMTP id h2mr25463113eem.34.1385825642995;\r
+       Sat, 30 Nov 2013 07:34:02 -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 m1sm46163441eeg.0.2013.11.30.07.34.01\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sat, 30 Nov 2013 07:34:02 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 1/7] cli: sanitize tabs and newlines to spaces in notmuch\r
+       search\r
+Date: Sat, 30 Nov 2013 17:33:50 +0200\r
+Message-Id:\r
+ <e2c281b2dbb78bdd71a1bd1e480874d29812afdd.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:09 -0000\r
+\r
+Sanitize tabs and newlines to spaces rather than question marks in\r
+--output=summary --format=text output.\r
+\r
+This will also hide any difference in unfolding a header that has been\r
+folded with a tab. Our own header parser replaces tabs with spaces,\r
+while gmime would retain the tab.\r
+---\r
+ notmuch-search.c   | 4 +++-\r
+ test/search-output | 2 +-\r
+ 2 files changed, 4 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 7c973b3..11cd6ee 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -41,7 +41,9 @@ sanitize_string (const void *ctx, const char *str)\r
+     loop = out = talloc_strdup (ctx, str);\r
\r
+     for (; *loop; loop++) {\r
+-      if ((unsigned char)(*loop) < 32)\r
++      if (*loop == '\t' || *loop == '\n')\r
++          *loop = ' ';\r
++      else if ((unsigned char)(*loop) < 32)\r
+           *loop = '?';\r
+     }\r
+     return out;\r
+diff --git a/test/search-output b/test/search-output\r
+index 5ccfeaf..86544ac 100755\r
+--- a/test/search-output\r
++++ b/test/search-output\r
+@@ -388,7 +388,7 @@ add_message "[subject]='two =?ISO-8859-1?Q?line=0A_subject?=\r
+       headers'"\r
+ notmuch search id:"$gen_msg_id" | notmuch_search_sanitize >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; two line? subject headers (inbox unread)\r
++thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; two line  subject headers (inbox unread)\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
\r
+-- \r
+1.8.4.2\r
+\r