]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] lua_selectors: reject selectors that parse only as a prefix
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 10 Jul 2026 13:16:11 +0000 (14:16 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 10 Jul 2026 13:16:11 +0000 (14:16 +0100)
commit5eb40ae6315504bbfefdca9bd274c6d68f2c705a
treef81f6e6fe44f7f8cf2d86dea9c50677d2db142ba
parent79bfda9b289d987e43610630661383b49f88636b
[Fix] lua_selectors: reject selectors that parse only as a prefix

The selector grammar was not anchored to the end of input, so lpeg
matched the longest valid prefix and silently dropped the rest of the
string. E.g. 'from("smtp"):domain:lower' (a second ':' cannot parse)
was accepted and evaluated as 'from("smtp"):domain', and any trailing
garbage after a selector or a ';' list element was ignored. All
consumers (multimap, rbl, ratelimit, settings, reputation, the
controller selector check used by the WebUI) reported such selectors
as valid while evaluating only the prefix.

Append an lpeg.Cp() capture after the grammar (plus optional trailing
whitespace) and make parse_selector require the whole input to be
consumed, logging the position and the unparsed tail otherwise.

User-visible change: selectors that previously loaded thanks to the
silent truncation now fail configuration load with an error pointing
at the offending token. Such selectors were never evaluating as
written, so failing loudly is the correct behaviour.
lualib/lua_selectors/init.lua