]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts-flatcurve: Remove fts_flatcurve_max_term_size setting
authorMarco Bettini <marco.bettini@open-xchange.com>
Wed, 22 Jan 2025 17:11:41 +0000 (17:11 +0000)
committerMarco Bettini <marco.bettini@open-xchange.com>
Thu, 23 Jan 2025 10:06:20 +0000 (10:06 +0000)
Note: the tokenizer already truncates with its own logic,
The truncation here is to ensure xapian is protected even if
tokenizer logics would change in future.

src/plugins/fts-flatcurve/fts-backend-flatcurve.c
src/plugins/fts-flatcurve/fts-flatcurve-settings.c
src/plugins/fts-flatcurve/fts-flatcurve-settings.h

index bd6a8b27f31ee084ca50317e6540aac89ea060cf..877edf98065343f4e6da91ac754cb6359bd4cba6 100644 (file)
@@ -13,6 +13,8 @@
 #include "fts-backend-flatcurve.h"
 #include "fts-backend-flatcurve-xapian.h"
 
+#define FTS_FLATCURVE_MAX_TERM_SIZE_MAX 200
+
 enum fts_backend_flatcurve_action {
        FTS_BACKEND_FLATCURVE_ACTION_OPTIMIZE,
        FTS_BACKEND_FLATCURVE_ACTION_RESCAN
@@ -320,12 +322,9 @@ fts_backend_flatcurve_update_build_more(struct fts_backend_update_context *_ctx,
                return 0;
 
        /* Xapian has a hard limit of "245 bytes", at least with the glass
-        * and chert backends.  However, it is highly doubtful that people
-        * are realistically going to search with more than 10s of
-        * characters. Therefore, limit term size (via a configurable
-        * value). */
+        * and chert backends. */
        size_t orig_size = size;
-       size = I_MIN(size, ctx->backend->fuser->set->max_term_size);
+       size = I_MIN(size, FTS_FLATCURVE_MAX_TERM_SIZE_MAX);
        size = uni_utf8_data_truncate(data, orig_size, size);
 
        const char *error;
index fc2e756a42fac9cda9991fdb81f1e5605dd16a1e..3ca04c75100e6221d898ac1e1c410018a68dc805 100644 (file)
@@ -8,16 +8,11 @@
 #define DEF(type, name) \
        SETTING_DEFINE_STRUCT_##type("fts_flatcurve_"#name, name, struct fts_flatcurve_settings)
 
-/* <settings checks> */
-#define FTS_FLATCURVE_MAX_TERM_SIZE_MAX 200
-/* </settings checks> */
-
 static const struct setting_define fts_flatcurve_setting_defines[] = {
        /* For now this filter just allows grouping the settings
           like it is possible in the other fts_backends. */
        { .type = SET_FILTER_NAME, .key = FTS_FLATCURVE_FILTER },
        DEF(UINT, commit_limit),
-       DEF(UINT, max_term_size),
        DEF(UINT, min_term_size),
        DEF(UINT, optimize_limit),
        DEF(UINT, rotate_count),
@@ -28,7 +23,6 @@ static const struct setting_define fts_flatcurve_setting_defines[] = {
 
 static const struct fts_flatcurve_settings fts_flatcurve_default_settings = {
        .commit_limit     =   500,
-       .max_term_size    =    30,
        .min_term_size    =     2,
        .optimize_limit   =    10,
        .rotate_count     =  5000,
@@ -36,36 +30,13 @@ static const struct fts_flatcurve_settings fts_flatcurve_default_settings = {
        .substring_search = FALSE,
 };
 
-/* <settings checks> */
-static bool fts_flatcurve_settings_check(void *_set, pool_t pool,
-                                        const char **error_r);
-/* </settings checks> */
-
 const struct setting_parser_info fts_flatcurve_setting_parser_info = {
        .name = "fts_flatcurve",
 
        .defines = fts_flatcurve_setting_defines,
        .defaults = &fts_flatcurve_default_settings,
-       .check_func = fts_flatcurve_settings_check,
 
        .struct_size = sizeof(struct fts_flatcurve_settings),
        .pool_offset1 = 1 + offsetof(struct fts_flatcurve_settings, pool),
 };
 
-/* <settings checks> */
-static bool fts_flatcurve_settings_check(void *_set, pool_t pool ATTR_UNUSED,
-                                        const char **error_r)
-{
-       struct fts_flatcurve_settings *set = _set;
-
-       if (set->max_term_size > FTS_FLATCURVE_MAX_TERM_SIZE_MAX) {
-               *error_r = t_strdup_printf(
-                       "Invalid fts_flatcurve_max_term_size '%u', "
-                       "allowed values: 0..%d",
-                       set->max_term_size, FTS_FLATCURVE_MAX_TERM_SIZE_MAX);
-               return FALSE;
-       }
-
-       return TRUE;
-}
-/* </settings checks> */
index b020399e8dfde7e4f4ea0a1662c61a8ac1a2554c..dbe61c2b3da4309aa60e7be3487feddc60241745 100644 (file)
@@ -8,7 +8,6 @@
 struct fts_flatcurve_settings {
        pool_t pool;
        unsigned int commit_limit;
-       unsigned int max_term_size;
        unsigned int min_term_size;
        unsigned int optimize_limit;
        unsigned int rotate_count;