diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-26 16:40:51 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-26 16:40:51 +0000 |
commit | 2dcb09b6eae0b21d4da68f9323be4cbfeb2b4237 (patch) | |
tree | 0a3751d753308c7b26c9b6495a06ac7d64345184 /src/plugins | |
parent | d2f95b4a010032f96a947b8ac63e1da51af14ad5 (diff) | |
download | rspamd-2dcb09b6eae0b21d4da68f9323be4cbfeb2b4237.tar.gz rspamd-2dcb09b6eae0b21d4da68f9323be4cbfeb2b4237.zip |
[Project] Use more generalised API to produce meta words
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/chartable.c | 38 |
1 files changed, 15 insertions, 23 deletions
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"); + } } |