--- /dev/null
+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 E8913431FBC\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:16 -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 DapZPzOilK5N for <notmuch@notmuchmail.org>;\r
+ Sat, 30 Nov 2013 07:34:11 -0800 (PST)\r
+Received: from mail-ea0-f174.google.com (mail-ea0-f174.google.com\r
+ [209.85.215.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 6A75E431FC7\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:08 -0800 (PST)\r
+Received: by mail-ea0-f174.google.com with SMTP id b10so7490094eae.19\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:07 -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=awJ8sTwb5zV9KmWYH7p/0CJsHSvVgVzVXv9ctBdYGDE=;\r
+ b=Ahw92OUn+d3zEv5VY0lE5NiCQV+8TNuowPeT+hj5bNtpL9uTmrbbClLn/y4/MtYq9T\r
+ 9+xWAbReT30bQxVByPq/ekHigTZkSNkXZa44Pc0mV7nBgsZcmULh43K35IOO7MLgH6hq\r
+ cbW5FeG68KYBYy+w3C8G+GgnE7oYtFpzGZwliec4mh0i5h3i1I6toiNtDLtta+TrqP9A\r
+ Mk8AA4bqRNJrpHk1wTfRCCA5Rh2t31aXpYHxeeiWWPNmtSeAKBE6Vt2YeKRvsHrRtxx8\r
+ jYIdbrJ37Df/G4hrMHOVfMqhFLvynn90FU+7vYHWIVab8qFoCQ5+MneUmr7LVGeCDGH4\r
+ 1VSQ==\r
+X-Gm-Message-State:\r
+ ALoCoQmscjeV69WeNI4ij2DIFhOCSr20xdoAVe/p01QG7JbtERukMcJM1Iw02f1siHEpC+l3SBf3\r
+X-Received: by 10.15.67.195 with SMTP id u43mr33405654eex.14.1385825647433;\r
+ Sat, 30 Nov 2013 07:34:07 -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 b42sm51870665eem.9.2013.11.30.07.34.06\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 30 Nov 2013 07:34:06 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/7] util: make sanitize string available in string util\r
+ for reuse\r
+Date: Sat, 30 Nov 2013 17:33:52 +0200\r
+Message-Id:\r
+ <6859d1e9de273e00101c10122cd8ca162cc3a542.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:17 -0000\r
+\r
+No functional changes.\r
+---\r
+ notmuch-search.c | 19 -------------------\r
+ util/string-util.c | 22 ++++++++++++++++++++++\r
+ util/string-util.h | 7 +++++++\r
+ 3 files changed, 29 insertions(+), 19 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 11cd6ee..8b6940a 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -30,25 +30,6 @@ typedef enum {\r
+ OUTPUT_TAGS\r
+ } output_t;\r
+ \r
+-static char *\r
+-sanitize_string (const void *ctx, const char *str)\r
+-{\r
+- char *out, *loop;\r
+-\r
+- if (NULL == str)\r
+- return NULL;\r
+-\r
+- loop = out = talloc_strdup (ctx, str);\r
+-\r
+- for (; *loop; loop++) {\r
+- if (*loop == '\t' || *loop == '\n')\r
+- *loop = ' ';\r
+- else if ((unsigned char)(*loop) < 32)\r
+- *loop = '?';\r
+- }\r
+- return out;\r
+-}\r
+-\r
+ /* Return two stable query strings that identify exactly the matched\r
+ * and unmatched messages currently in thread. If there are no\r
+ * matched or unmatched messages, the returned buffers will be\r
+diff --git a/util/string-util.c b/util/string-util.c\r
+index a5622d7..9e2f728 100644\r
+--- a/util/string-util.c\r
++++ b/util/string-util.c\r
+@@ -37,6 +37,28 @@ strtok_len (char *s, const char *delim, size_t *len)\r
+ return *len ? s : NULL;\r
+ }\r
+ \r
++char *\r
++sanitize_string (const void *ctx, const char *str)\r
++{\r
++ char *out, *loop;\r
++\r
++ if (! str)\r
++ return NULL;\r
++\r
++ out = talloc_strdup (ctx, str);\r
++ if (! out)\r
++ return NULL;\r
++\r
++ for (loop = out; *loop; loop++) {\r
++ if (*loop == '\t' || *loop == '\n')\r
++ *loop = ' ';\r
++ else if ((unsigned char)(*loop) < 32)\r
++ *loop = '?';\r
++ }\r
++\r
++ return out;\r
++}\r
++\r
+ static int\r
+ is_unquoted_terminator (unsigned char c)\r
+ {\r
+diff --git a/util/string-util.h b/util/string-util.h\r
+index 0194607..228420d 100644\r
+--- a/util/string-util.h\r
++++ b/util/string-util.h\r
+@@ -19,6 +19,13 @@\r
+ \r
+ char *strtok_len (char *s, const char *delim, size_t *len);\r
+ \r
++/* Return a talloced string with str sanitized.\r
++ *\r
++ * Whitespace (tabs and newlines) is replaced with spaces,\r
++ * non-printable characters with question marks.\r
++ */\r
++char *sanitize_string (const void *ctx, const char *str);\r
++\r
+ /* Construct a boolean term query with the specified prefix (e.g.,\r
+ * "id") and search term, quoting term as necessary. Specifically, if\r
+ * term contains any non-printable ASCII characters, non-ASCII\r
+-- \r
+1.8.4.2\r
+\r