]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fts: Update error message for the case where a stopword list is empty.
authorMarco Bettini <marco.bettini@open-xchange.com>
Tue, 11 Oct 2022 12:38:09 +0000 (12:38 +0000)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Oct 2022 16:35:08 +0000 (16:35 +0000)
Now this condition is no longer allowed.

src/lib-fts/fts-filter-stopwords.c
src/lib-fts/test-fts-filter.c

index 3440cfe0ab57f1cd216d73c2226d39022092ca6c..ca27e6be48e10239a6a50ea34a45a6885b1aa198 100644 (file)
@@ -50,8 +50,12 @@ static int fts_filter_stopwords_read_list(struct fts_filter_stopwords *filter,
                ret = -1;
        }
 
-       if (ret == 0 && hash_table_count(filter->stopwords) == 0)
-               i_warning("Stopwords list \"%s\" seems empty. Is the file correctly formatted?", path);
+       if (ret == 0 && hash_table_count(filter->stopwords) == 0) {
+               *error_r = t_strdup_printf("Stopwords list \"%s\" seems empty. "
+                                          "Is the file correctly formatted?",
+                                          path);
+               ret = -1;
+       }
 
        i_stream_destroy(&input);
        return ret;
index de64e4f43958dc5a9963b5ffdf347f65191d89ec..8c5825b29e36346d4c8520d6eb2d4c511a145b0f 100644 (file)
@@ -385,8 +385,8 @@ static void test_fts_filter_stopwords_malformed(void)
 
        test_begin("fts filter stopwords, malformed list");
        test_assert(fts_filter_create(fts_filter_stopwords, NULL, &malformed, stopword_settings, &filter, &error) == 0);
-       test_expect_error_string("seems empty. Is the file correctly formatted?");
-       test_assert(fts_filter_filter(filter, &token, &error) > 0);
+       test_assert(fts_filter_filter(filter, &token, &error) < 0);
+       test_assert(strstr(error, "seems empty. Is the file correctly formatted?") != NULL);
        test_expect_no_more_errors();
        fts_filter_unref(&filter);
        test_end();