]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to reset score of an action
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Mar 2018 13:17:40 +0000 (13:17 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Mar 2018 13:25:58 +0000 (13:25 +0000)
Issue: 2088

src/libserver/cfg_rcl.c

index a01f42ea6f0c166bbada13d0db7828b50bcb37bf..08c7c7868cee217712c7ee7cf11c38f9b431c538 100644 (file)
@@ -38,6 +38,8 @@
 #include <glob.h>
 #endif
 
+#include <math.h>
+
 struct rspamd_rcl_default_handler_data {
        struct rspamd_rcl_struct_parser pd;
        gchar *key;
@@ -450,16 +452,22 @@ rspamd_rcl_actions_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
                        continue;
                }
                else {
-                       if (!ucl_object_todouble_safe (cur, &action_score)) {
-                               g_set_error (err,
-                                               CFG_RCL_ERROR,
-                                               EINVAL,
-                                               "invalid action definition: '%s'",
-                                               ucl_object_key (cur));
-                               ucl_object_iterate_free (it);
+                       if (ucl_object_type (cur) == UCL_NULL) {
+                               action_score = NAN;
+                       }
+                       else {
+                               if (!ucl_object_todouble_safe (cur, &action_score)) {
+                                       g_set_error (err,
+                                                       CFG_RCL_ERROR,
+                                                       EINVAL,
+                                                       "invalid action definition: '%s'",
+                                                       ucl_object_key (cur));
+                                       ucl_object_iterate_free (it);
 
-                               return FALSE;
+                                       return FALSE;
+                               }
                        }
+
                        rspamd_config_set_action_score (cfg,
                                        ucl_object_key (cur),
                                        action_score,