]> source.dussan.org Git - rspamd.git/commitdiff
[Project] Allow rspamd_text based selectors
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 May 2020 14:37:48 +0000 (15:37 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 May 2020 15:35:43 +0000 (16:35 +0100)
lualib/lua_selectors/init.lua

index 7f20e2cbb1b639b75b9f4cd6c522d6b58db4853c..11fcd55d1c27e3d4f2d92a8f3b04b8e8b1a67791 100644 (file)
@@ -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