commit 3dfad0d: [Project] Allow rspamd_text based selectors

Vsevolod Stakhov vsevolod at highsecure.ru
Wed May 13 15:42:15 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-05-13 15:37:48 +0100
URL: https://github.com/rspamd/rspamd/commit/3dfad0da61cb1bd1b68f9f456d051da3f77996a9

[Project] Allow rspamd_text based selectors

---
 lualib/lua_selectors/init.lua | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lualib/lua_selectors/init.lua b/lualib/lua_selectors/init.lua
index 7f20e2cbb..11fcd55d1 100644
--- a/lualib/lua_selectors/init.lua
+++ b/lualib/lua_selectors/init.lua
@@ -34,11 +34,14 @@ local logger = require 'rspamd_logger'
 local fun = require 'fun'
 local lua_util = require "lua_util"
 local M = "selectors"
+local rspamd_text = require "rspamd_text"
 local E = {}
 
 local extractors = require "lua_selectors/extractors"
 local transform_function = require "lua_selectors/transforms"
 
+local text_cookie = rspamd_text.cookie
+
 local function pure_type(ltype)
   return ltype:match('^(.*)_list$')
 end
@@ -66,6 +69,13 @@ local function process_selector(task, sel)
       end
 
       return logger.slog("%s", ud_or_table),'string'
+    elseif t == 'userdata' then
+      if t.cookie and t.cookie == text_cookie then
+        -- Preserve opaque
+        return ud_or_table,'string'
+      else
+        return tostring(ud_or_table),'string'
+      end
     else
       return tostring(ud_or_table),'string'
     end


More information about the Commits mailing list