[PATCH v3 1/6] cli: sanitize tabs and newlines to spaces in notmuch search
authorJani Nikula <jani@nikula.org>
Mon, 3 Feb 2014 19:51:41 +0000 (21:51 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:38 +0000 (09:59 -0800)
71/9a71330e110513b1f1054c9e2492fe14c095d0 [new file with mode: 0644]

diff --git a/71/9a71330e110513b1f1054c9e2492fe14c095d0 b/71/9a71330e110513b1f1054c9e2492fe14c095d0
new file mode 100644 (file)
index 0000000..1f008c3
--- /dev/null
@@ -0,0 +1,112 @@
+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 31D93429E2E\r
+       for <notmuch@notmuchmail.org>; Mon,  3 Feb 2014 11:52:05 -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 0bDdN6qkOelq for <notmuch@notmuchmail.org>;\r
+       Mon,  3 Feb 2014 11:51:59 -0800 (PST)\r
+Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com\r
+ [74.125.83.46])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 946CB431FBC   for <notmuch@notmuchmail.org>; Mon,  3 Feb 2014 11:51:59 -0800\r
+ (PST)\r
+Received: by mail-ee0-f46.google.com with SMTP id c13so3820980eek.19\r
+       for <notmuch@notmuchmail.org>; Mon, 03 Feb 2014 11:51:55 -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=YiOooJ8S+StSl6Ci8Gb4VwSwSckzNuXaBtDhOz83PCo=;\r
+       b=B9eEnmkqmByE7lpx9BZM9cuxCN2/XQpSY7ovVdn3Ezs9JFxyv+SrB2SHbALxLsxT7x\r
+       gyqRoHkKTOTGK1xZtLWRJ6/FINHGq2aHcyxf93WILe2vANCPRCcncuesxJoouwJckkcE\r
+       ypxzdQ3le2DiGOL0MKUbvb9PV7Y6urJyLJzxuPbwE5pFyEsAvOiBGciXRbQzg2nvvNGL\r
+       b85yblA5hjmd6DLZ80WPsrGcW7epGzxD/kOOsDrf4iikPZ6OGThmbVVXdt7PXCH7/tYn\r
+       MJDKEZHYd9xL6gwwZGWdxCytEwVH9X2gryNC+adMtqvUSsGF0kbaLOFPB683nhS1q0Nw\r
+       FMMg==\r
+X-Gm-Message-State:\r
+ ALoCoQlnUZhSEm5W+hKmdpwiZp3ZRBk/bN4XBnGktvMk15bwDuhXK0U0zw8+y5F9zZDU6ELQtqGH\r
+X-Received: by 10.14.106.193 with SMTP id m41mr5147647eeg.62.1391457115851;\r
+       Mon, 03 Feb 2014 11:51:55 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91]) by mx.google.com with ESMTPSA id\r
+       j42sm79872675eep.21.2014.02.03.11.51.53 for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Mon, 03 Feb 2014 11:51:55 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 1/6] cli: sanitize tabs and newlines to spaces in notmuch\r
+       search\r
+Date: Mon,  3 Feb 2014 21:51:41 +0200\r
+Message-Id:\r
+ <69cbcc33a4f0701ce39950510ff59c921eee6bc0.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:05 -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/T090-search-output.sh | 2 +-\r
+ 2 files changed, 4 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 91b5d10..0262eb3 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/T090-search-output.sh b/test/T090-search-output.sh\r
+index 5ccfeaf..86544ac 100755\r
+--- a/test/T090-search-output.sh\r
++++ b/test/T090-search-output.sh\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.5.2\r
+\r