diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-12 12:31:43 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-12 12:31:43 +0100 |
commit | 44ba38e31c3ee6c5773ee805084099d51f7f46f8 (patch) | |
tree | 28993aa984949ce8ad863692a6c0e0855430cb56 /src/libstat/stat_process.c | |
parent | 7d7b3200affdeefabbf8eb2066ec579a46a91db5 (diff) | |
download | rspamd-44ba38e31c3ee6c5773ee805084099d51f7f46f8.tar.gz rspamd-44ba38e31c3ee6c5773ee805084099d51f7f46f8.zip |
[Fix] Do not classify when a message has not enough tokens
Issue: #556
MFH: true
Diffstat (limited to 'src/libstat/stat_process.c')
-rw-r--r-- | src/libstat/stat_process.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 0d3795f4d..71983f10f 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -370,6 +370,27 @@ rspamd_stat_classifiers_process (struct rspamd_stat_ctx *st_ctx, cl = g_ptr_array_index (st_ctx->classifiers, i); g_assert (cl != NULL); + if (cl->cfg->min_tokens > 0 && task->tokens->len < cl->cfg->min_tokens) { + msg_debug_task ( + "<%s> contains less tokens than required for %s classifier: " + "%ud < %ud", + task->message_id, + cl->cfg->name, + task->tokens->len, + cl->cfg->min_tokens); + continue; + } + else if (cl->cfg->max_tokens > 0 && task->tokens->len > cl->cfg->max_tokens) { + msg_debug_task ( + "<%s> contains more tokens than allowed for %s classifier: " + "%ud > %ud", + task->message_id, + cl->cfg->name, + task->tokens->len, + cl->cfg->max_tokens); + continue; + } + cl->subrs->classify_func (cl, task->tokens, task); } } |