From 3cb96c8db92dc3059244f0977a79599b897a59b6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Oct 2005 05:53:46 +0000 Subject: r10756: another fix for the construction of expressions from subtrees for SUBSTRING searches. This time fix multi-part substring searches. (This used to be commit bf5cef6f00466fc1dc3c2864a109f1ccd92681b0) --- source4/lib/ldb/common/ldb_parse.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index 110361d2b7..27f9e1ec25 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -695,16 +695,18 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree) talloc_free(ret); return NULL; } - s = talloc_asprintf_append(ret, "%s*", s2); + if (tree->u.substring.chunks[i+1] || + tree->u.substring.end_with_wildcard) { + s = talloc_asprintf_append(ret, "%s*", s2); + } else { + s = talloc_asprintf_append(ret, "%s", s2); + } if (s == NULL) { talloc_free(ret); return NULL; } ret = s; } - if ( ! tree->u.substring.end_with_wildcard ) { - ret[strlen(ret) - 1] = '\0'; /* remove last wildcard */ - } s = talloc_asprintf_append(ret, ")"); if (s == NULL) { talloc_free(ret); -- cgit