From: Marco Bettini Date: Tue, 11 Oct 2022 12:38:09 +0000 (+0000) Subject: lib-fts: Update error message for the case where a stopword list is empty. X-Git-Tag: 2.4.0~3520 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e738fbf8ef026ae892c25b187d47c1f83707fb9;p=thirdparty%2Fdovecot%2Fcore.git lib-fts: Update error message for the case where a stopword list is empty. Now this condition is no longer allowed. --- diff --git a/src/lib-fts/fts-filter-stopwords.c b/src/lib-fts/fts-filter-stopwords.c index 3440cfe0ab..ca27e6be48 100644 --- a/src/lib-fts/fts-filter-stopwords.c +++ b/src/lib-fts/fts-filter-stopwords.c @@ -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; diff --git a/src/lib-fts/test-fts-filter.c b/src/lib-fts/test-fts-filter.c index de64e4f439..8c5825b29e 100644 --- a/src/lib-fts/test-fts-filter.c +++ b/src/lib-fts/test-fts-filter.c @@ -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();