aboutsummaryrefslogtreecommitdiffhomepage
path: root/util
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@MIT.EDU>2014-03-11 16:42:00 -0400
committerGravatar David Bremner <david@tethera.net>2014-03-15 15:05:06 -0300
commit3fed6736a7ef8b8b1f05d0fabb136bdd3b5917ee (patch)
treedff4a62872f617e974054a8b51d197a5d1c41cba /util
parent8fcc3260a9a936de72d755e61d93d5a24380e8b7 (diff)
util: Fix two corner-cases in boolean term quoting function
Previously, make_boolean_term did not quote empty boolean terms or boolean terms that started with '('. These cases are incompatible with Xapian: empty terms cannot be omitted, and boolean terms that start with '(' trigger an alternate term quoting syntax. Fix this by quoting empty terms and terms that contain '('.
Diffstat (limited to 'util')
-rw-r--r--util/string-util.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/string-util.c b/util/string-util.c
index 9e2f728f..3e7066cd 100644
--- a/util/string-util.c
+++ b/util/string-util.c
@@ -75,10 +75,12 @@ 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. */
+ if (! term[0])
+ need_quoting = 1;
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;