]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] lua_selectors: don't crash on a missing method call
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 5 Jul 2026 11:43:13 +0000 (12:43 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 5 Jul 2026 11:43:29 +0000 (12:43 +0100)
commiteb7fc38bec41111ec5b29c3ccdef032ee09145d3
treed34f651af2e71a2bd02ba9409ade206a3d36c1c9
parent73aa2093a7d8c136fe8dcaa8b7a292bf477b7172
[Fix] lua_selectors: don't crash on a missing method call

Selectors like `time:digest` (method syntax used where a transform
was meant) aborted the whole selector at scan time with an uncaught
Lua error:

  Cannot run callback: .../lua_selectors/init.lua: attempt to call
  a nil value

The `:` separator always compiles to a method call on the extracted
value; when the value has no such method, the lookup yields nil and
the unguarded call crashed the callback. Guard the lookup (via pcall,
since indexing some types raises) and yield no value instead, logging
an error that hints at the `.name` transform syntax when the name
matches a known transform. Valid method calls (e.g. `:gsub`,
`:lower`) and table field access are unaffected.
lualib/lua_selectors/init.lua
test/lua/unit/selectors.lua