[PATCH] util: Fix corner-case in boolean term quoting function

Subject: [PATCH] util: Fix corner-case in boolean term quoting function

Date: Tue, 11 Mar 2014 16:03:05 -0400

To: notmuch@notmuchmail.org

Cc:

From: Austin Clements


Previously, make_boolean_term did not quote boolean terms that started
with '('.  This is incompatible with Xapian, since boolean terms that
start with '(' trigger an alternate term quoting syntax.

Fix this by quoting terms that contain '('.
---
 util/string-util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/util/string-util.c b/util/string-util.c
index 9e2f728..fd3ceb2 100644
--- a/util/string-util.c
+++ b/util/string-util.c
@@ -75,10 +75,10 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,
     int need_quoting = 0;
 
     /* Do we need quoting?  To be paranoid, we quote anything
-     * containing a quote, even though it only matters at the
+     * containing a quote or '(', even though these only matter at the
      * beginning, and anything containing non-ASCII text. */
     for (in = term; *in && !need_quoting; in++)
-	if (is_unquoted_terminator (*in) || *in == '"'
+	if (is_unquoted_terminator (*in) || *in == '"' || *in == '('
 	    || (unsigned char)*in > 127)
 	    need_quoting = 1;
 
-- 
1.8.4.rc3


Thread: