]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix allowed_settings for neural
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Feb 2020 13:02:40 +0000 (13:02 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Feb 2020 13:02:40 +0000 (13:02 +0000)
Issue: #3270

lualib/lua_settings.lua
src/plugins/lua/neural.lua

index 61cc9d2ad937f32f250ea36e50ef70dda6ba4bae..bb0ea04576e398e16fe31e97701da62bbfbc8950 100644 (file)
@@ -170,6 +170,8 @@ local function numeric_settings_id(str)
   return ret
 end
 
+exports.numeric_settings_id = numeric_settings_id
+
 -- Used to do the following:
 -- If there is a group of symbols_allowed, it checks if that is an array
 -- If that is a hash table then we transform it to a normal list, probably adding symbols to adjust scores
index 12dadd8d6ffff2b50658514fc06bc8c316f24ce6..da569e69853f7154e4d19bab1a253bd0d983fd9f 100644 (file)
@@ -1293,7 +1293,11 @@ local function process_rules_settings()
     -- We set table rule.settings[id] -> { name = name, symbols = symbols, digest = digest }
     for s,_ in pairs(rule.allowed_settings) do
       -- Here, we have a name, set of symbols and
-      local selt = lua_settings.settings_by_id(s)
+      local settings_id = s
+      if type(settings_id) ~= 'number' then
+        settings_id = lua_settings.numeric_settings_id(s)
+      end
+      local selt = lua_settings.settings_by_id(settings_id)
 
       local nelt = {
         symbols = selt.symbols, -- Already sorted
@@ -1308,16 +1312,16 @@ local function process_rules_settings()
             lua_util.debugm(N, rspamd_config,
                 'added reference from settings id %s to %s; same symbols',
                 nelt.name, ex.name)
-            rule.settings[s] = id
+            rule.settings[settings_id] = id
             nelt = nil
           end
         end
       end
 
       if nelt then
-        rule.settings[s] = nelt
-        lua_util.debugm(N, rspamd_config, 'added new settings id %s to %s',
-            nelt.name, rule.prefix)
+        rule.settings[settings_id] = nelt
+        lua_util.debugm(N, rspamd_config, 'added new settings id %s(%s) to %s',
+            nelt.name, settings_id, rule.prefix)
       end
     end
   end