diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-20 18:24:19 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-20 18:24:19 +0000 |
commit | 64c930e180b11722c6905651fae65f85a52fb13e (patch) | |
tree | 6f2f44b6766833066b2a9e6e5eee760729b4422b | |
parent | c11152d9ec349554710f8104ef3b2321cfe8a068 (diff) | |
download | rspamd-64c930e180b11722c6905651fae65f85a52fb13e.tar.gz rspamd-64c930e180b11722c6905651fae65f85a52fb13e.zip |
[Fix] Fix options and shots match
-rw-r--r-- | src/libmime/filter.c | 75 | ||||
-rw-r--r-- | src/lua/lua_config.c | 2 |
2 files changed, 43 insertions, 34 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 2a6bbae6d..ed949a86a 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -159,48 +159,57 @@ insert_metric_result (struct rspamd_task *task, single = TRUE; } - s->nshots ++; + /* Now check for the duplicate options */ + if (opt && s->options && g_hash_table_lookup (s->options, opt)) { + single = TRUE; + } + else { + s->nshots ++; + } + + if (!single) { + rspamd_task_add_result_option (task, s, opt); + } - if (rspamd_task_add_result_option (task, s, opt)) { - if (!single) { - diff = w; + /* Adjust diff */ + if (!single) { + diff = w; + } + else { + if (fabs (s->score) < fabs (w)) { + /* Replace less weight with a bigger one */ + diff = metric_res->score - s->score + w; } else { - if (fabs (s->score) < fabs (w)) { - /* Replace less weight with a bigger one */ - diff = metric_res->score - s->score + w; - } - else { - diff = 0; - } + diff = 0; } + } - if (diff) { - /* Handle grow factor */ - if (metric_res->grow_factor && diff > 0) { - diff *= metric_res->grow_factor; - next_gf *= metric->grow_factor; - } - else if (diff > 0) { - next_gf = metric->grow_factor; - } + if (diff) { + /* Handle grow factor */ + if (metric_res->grow_factor && diff > 0) { + diff *= metric_res->grow_factor; + next_gf *= metric->grow_factor; + } + else if (diff > 0) { + next_gf = metric->grow_factor; + } - diff = rspamd_check_group_score (task, symbol, gr, gr_score, diff); + diff = rspamd_check_group_score (task, symbol, gr, gr_score, diff); - if (!isnan (diff)) { - metric_res->score += diff; - metric_res->grow_factor = next_gf; + if (!isnan (diff)) { + metric_res->score += diff; + metric_res->grow_factor = next_gf; - if (gr_score) { - *gr_score += diff; - } + if (gr_score) { + *gr_score += diff; + } - if (single) { - s->score = w; - } - else { - s->score += diff; - } + if (single) { + s->score = w; + } + else { + s->score += diff; } } } diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index e83e9a699..654035dab 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -1499,7 +1499,7 @@ lua_config_set_metric_symbol (lua_State * L) "nshots=I", &name, &weight, &description, &group, &one_shot, &one_param, - &metric_name, &priority, &flags_str)) { + &metric_name, &priority, &flags_str, &nshots)) { msg_err_config ("bad arguments: %e", err); g_error_free (err); |