commit 45d897b: [Fix] Settings: Fix selectors usage

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Dec 27 18:28:06 UTC 2018


Author: Vsevolod Stakhov
Date: 2018-12-11 19:43:10 +0000
URL: https://github.com/rspamd/rspamd/commit/45d897b7baf8671da3618750ae91e3b17cc91be9

[Fix] Settings: Fix selectors usage

---
 src/plugins/lua/settings.lua | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 970062d3b..7ad85d184 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -316,22 +316,8 @@ local function check_settings(task)
       end
     end
 
-    if rule['selector'] then
-      local sel = selectors_cache[rule_name]
-      if not sel then
-        sel = lua_selectors.create_selector_closure(rspamd_config, rule.selector,
-            rule.delimiter or "")
-
-        if sel then
-          selectors_cache[rule_name] = sel
-        end
-      end
-
-      if sel then
-        if sel(task) then
-          res = true
-        end
-      end
+    if rule.selector then
+      res = rule.selector(task)
     end
 
     if res then
@@ -602,6 +588,22 @@ local function process_settings_table(tbl)
       end
     end
 
+    if elt['selector'] then
+      local sel = selectors_cache[name]
+      if not sel then
+        sel = lua_selectors.create_selector_closure(rspamd_config, elt.selector,
+            elt.delimiter or "")
+
+        if sel then
+          selectors_cache[name] = sel
+        end
+      end
+
+      if sel then
+        out['selector'] = sel
+      end
+    end
+
     -- Now we must process actions
     if elt['symbols'] then out['symbols'] = elt['symbols'] end
     if elt['id'] then


More information about the Commits mailing list