]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb: ldb_comparison_fold always uses the casecmp function
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 16 May 2024 05:01:10 +0000 (17:01 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 22 May 2024 23:12:32 +0000 (23:12 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/common/attrib_handlers.c

index 06a96c25a9f3be5e66d140b70d7ccb1c28613d3a..1c37b6060601374fff1b0491ce02fcbec68605d3 100644 (file)
@@ -334,6 +334,7 @@ int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
   try to optimize for the ascii case,
   but if we find out an utf8 codepoint revert to slower but correct function
 */
+__attribute__ ((unused))
 static int ldb_comparison_fold_utf8_broken(struct ldb_context *ldb, void *mem_ctx,
                                           const struct ldb_val *v1, const struct ldb_val *v2)
 {
@@ -469,14 +470,19 @@ utf8str:
        return ret;
 }
 
-
+/*
+ * ldb_comparison_fold is a schema syntax comparison_fn for utf-8 strings that
+ * collapse multiple spaces into one (e.g. "Directory String" syntax).
+ *
+ * The default comparison function only performs ASCII case-folding, and only
+ * collapses multiple spaces, not tabs and other whitespace (contrary to
+ * RFC4518). To change the comparison function (as Samba does), use
+ * ldb_set_utf8_functions().
+ */
 int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
                        const struct ldb_val *v1, const struct ldb_val *v2)
 {
-       if (ldb->utf8_fns.casecmp) {
-               return ldb->utf8_fns.casecmp(ldb->utf8_fns.context, v1, v2);
-       }
-       return ldb_comparison_fold_utf8_broken(ldb, mem_ctx, v1, v2);
+       return ldb->utf8_fns.casecmp(ldb->utf8_fns.context, v1, v2);
 }