From 2dcb09b6eae0b21d4da68f9323be4cbfeb2b4237 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 26 Nov 2018 16:40:51 +0000 Subject: [Project] Use more generalised API to produce meta words --- src/plugins/chartable.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c index c566cc517..e48d19ea2 100644 --- a/src/plugins/chartable.c +++ b/src/plugins/chartable.c @@ -621,35 +621,27 @@ chartable_symbol_callback (struct rspamd_task *task, rspamd_chartable_process_part (task, part, chartable_module_ctx); } - if (task->subject != NULL) { - GArray *words; + if (task->meta_words != NULL) { rspamd_stat_token_t *w; - gdouble cur_score = 0.0; + gdouble cur_score = 0; + gsize arlen = task->meta_words->len; - words = rspamd_tokenize_subject (task); - - if (words && words->len > 0) { - for (i = 0; i < words->len; i++) { - w = &g_array_index (words, rspamd_stat_token_t, i); - cur_score += rspamd_chartable_process_word_utf (task, w, FALSE, - NULL, chartable_module_ctx); - } - - cur_score /= (gdouble)words->len; - - if (cur_score > 2.0) { - cur_score = 2.0; - } + for (i = 0; i < arlen; i++) { + w = &g_array_index (task->meta_words, rspamd_stat_token_t, i); + cur_score += rspamd_chartable_process_word_utf (task, w, FALSE, + NULL, chartable_module_ctx); + } - if (cur_score > chartable_module_ctx->threshold) { - rspamd_task_insert_result (task, chartable_module_ctx->symbol, - cur_score, "subject"); + cur_score /= (gdouble)arlen; - } + if (cur_score > 2.0) { + cur_score = 2.0; } - if (words) { - g_array_free (words, TRUE); + if (cur_score > chartable_module_ctx->threshold) { + rspamd_task_insert_result (task, chartable_module_ctx->symbol, + cur_score, "subject"); + } } -- cgit v1.2.3