]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Some fixes in least passthrough results processing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 29 Apr 2019 10:41:28 +0000 (11:41 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 29 Apr 2019 10:41:28 +0000 (11:41 +0100)
src/libmime/filter.c
src/lua/lua_task.c

index c3f3089f858919fa98bcdda00422aac17c6da9b8..a454cb8df8784b11efe1968333bd62d54ea6f49a 100644 (file)
@@ -503,25 +503,33 @@ rspamd_check_action_metric (struct rspamd_task *task)
        gboolean seen_least = FALSE;
 
        if (mres->passthrough_result != NULL)  {
-               /* Peek the highest priority result */
-               pr = mres->passthrough_result;
-               sc = pr->target_score;
-               selected_action = pr->action;
-
-               if (!(pr->flags & RSPAMD_PASSTHROUGH_LEAST)) {
-                       if (!isnan (sc)) {
-                               if (pr->action->action_type == METRIC_ACTION_NOACTION) {
-                                       mres->score = MIN (sc, mres->score);
+               DL_FOREACH (mres->passthrough_result, pr) {
+                       if (!seen_least || !(pr->flags & RSPAMD_PASSTHROUGH_LEAST)) {
+                               sc = pr->target_score;
+                               selected_action = pr->action;
+
+                               if (!(pr->flags & RSPAMD_PASSTHROUGH_LEAST)) {
+                                       if (!isnan (sc)) {
+                                               if (pr->action->action_type == METRIC_ACTION_NOACTION) {
+                                                       mres->score = MIN (sc, mres->score);
+                                               }
+                                               else {
+                                                       mres->score = sc;
+                                               }
+                                       }
+
+                                       return selected_action;
                                }
                                else {
-                                       mres->score = sc;
+                                       seen_least = true;
+
+                                       if (isnan (sc)) {
+                                               sc = selected_action->threshold;
+                                       }
+
+                                       max_score = sc;
                                }
                        }
-
-                       return selected_action;
-               }
-               else {
-                       seen_least = true;
                }
        }
        /* We are not certain about the results during processing */
@@ -555,7 +563,7 @@ rspamd_check_action_metric (struct rspamd_task *task)
        if (selected_action) {
 
                if (seen_least) {
-                       mres->score = MIN (sc, mres->score);
+                       mres->score = MAX (max_score, mres->score);
                }
 
                return selected_action;
index 6a4ae145d685aef505fe52a101c0212d2a417537..6a6413e7fef5c4973f840d295b62f92e309ec8f0 100644 (file)
@@ -1809,11 +1809,14 @@ lua_task_set_pre_result (lua_State * L)
                if (lua_type (L, 3) == LUA_TSTRING) {
                        message = lua_tostring (L, 3);
 
-                       /* Keep compatibility here :( */
-                       ucl_object_replace_key (task->messages,
-                                       ucl_object_fromstring_common (message, 0, UCL_STRING_RAW),
-                                       "smtp_message", 0,
-                                       false);
+                       if (lua_type (L, 7) != LUA_TSTRING) {
+                               /* Keep compatibility here :( */
+
+                               ucl_object_replace_key (task->messages,
+                                               ucl_object_fromstring_common (message, 0, UCL_STRING_RAW),
+                                               "smtp_message", 0,
+                                               false);
+                       }
                }
                else {
                        message = "unknown reason";