diff options
author | rm-minus-rf <rm.minus.rf@protonmail.com> | 2020-04-18 00:17:29 +0200 |
---|---|---|
committer | rm-minus-rf <rm.minus.rf@protonmail.com> | 2020-04-18 00:17:29 +0200 |
commit | 00b2ecaa3b1ec5629a1c37781af80b7afa23913b (patch) | |
tree | 4a1a2ceed45afd012871fd633507c3b676eb8166 /lualib/lua_selectors/extractors.lua | |
parent | e1e23ddef268163cec9e1d1fafbfda0b36917e77 (diff) | |
download | rspamd-00b2ecaa3b1ec5629a1c37781af80b7afa23913b.tar.gz rspamd-00b2ecaa3b1ec5629a1c37781af80b7afa23913b.zip |
[Minor] selectors: cleaner symbol extractor
'symbol' extractor returns a table
'to_ascii' transform can handle tables
Diffstat (limited to 'lualib/lua_selectors/extractors.lua')
-rw-r--r-- | lualib/lua_selectors/extractors.lua | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lualib/lua_selectors/extractors.lua b/lualib/lua_selectors/extractors.lua index 635972226..695371e79 100644 --- a/lualib/lua_selectors/extractors.lua +++ b/lualib/lua_selectors/extractors.lua @@ -419,21 +419,12 @@ The first argument must be header name.]], ['symbol'] = { ['get_value'] = function(task, args) local symbol = task:get_symbol(args[1]) - if args[2] and symbol then - if args[2] == 'options' then - -- concat options tables to avoid table representation strings produced by implicit conversion - return fun.map(function(r) return table.concat(r[args[2]], ', ') end, symbol), 'string_list' - elseif args[2] == 'score' then - -- only userdata_list seems to work for scores - return fun.map(function(r) return r[args[2]] end, symbol), 'userdata_list' - else - return fun.map(function(r) return r[args[2]] end, symbol), 'string_list' - end + if symbol then + return symbol[1],'table' end - return symbol,'table_list' end, - ['description'] = [[Get specific symbol. The first argument must be the symbol name. If no second argument is specified, returns a list of symbol tables. Otherwise the second argument specifies the attribute which is returned as list (`options`, `score` or `group`)]], - ['args_schema'] = {ts.string, ts.one_of{'options','score','group'}:is_optional()} + ['description'] = [[Get specific symbol. The first argument must be the symbol name. Returns the symbol table. See task:get_symbol()]], + ['args_schema'] = {ts.string} }, } |