aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/gpt.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-07-22 13:25:39 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-07-22 13:25:39 +0100
commit58d13149875a44329c54567387241b642cc96471 (patch)
treec47498a98ea10b9ca9b67d85e60e5688108619d5 /src/plugins/lua/gpt.lua
parent272c3aa423eb74eff38bd8836acff744b9ea143b (diff)
downloadrspamd-58d13149875a44329c54567387241b642cc96471.tar.gz
rspamd-58d13149875a44329c54567387241b642cc96471.zip
[Minor] Ensure some safety when checking weights
Issue: #5065
Diffstat (limited to 'src/plugins/lua/gpt.lua')
-rw-r--r--src/plugins/lua/gpt.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua
index 7b582e55d..65b5758a8 100644
--- a/src/plugins/lua/gpt.lua
+++ b/src/plugins/lua/gpt.lua
@@ -106,10 +106,12 @@ local function default_condition(task)
if task:has_symbol(s) then
if required_weight > 0 then
-- Also check score
- local sym = task:get_symbol(s)
+ local sym = task:get_symbol(s) or E
-- Must exist as we checked it before with `has_symbol`
- if math.abs(sym.weight) >= required_weight then
- return false, 'skip as "' .. s .. '" is found (weight: ' .. sym.weight .. ')'
+ if sym.weight then
+ if math.abs(sym.weight) >= required_weight then
+ return false, 'skip as "' .. s .. '" is found (weight: ' .. sym.weight .. ')'
+ end
end
lua_util.debugm(N, task, 'symbol %s has weight %s, but required %s', s,
sym.weight, required_weight)