]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add id selector transform function
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 22 Aug 2018 14:50:14 +0000 (15:50 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 22 Aug 2018 14:50:14 +0000 (15:50 +0100)
lualib/lua_selectors.lua

index 3cf9a1340376d27cd0bdfddc3e55dbef9357e7d3..995617ca06731439b3c3453fce7474937ee88d7d 100644 (file)
@@ -360,6 +360,22 @@ local transform_function = {
       return inp:sub(start_pos, end_pos), 'string'
     end
   },
+  -- Drops input value and return values from function's arguments or an empty string
+  ['id'] = {
+    ['types'] = {
+      ['string'] = true
+    },
+    ['map_type'] = 'string',
+    ['process'] = function(_, _, args)
+      if args[1] and args[2] then
+        return fun.map(tostring, args)
+      elseif args[1] then
+        return args[1]
+      end
+
+      return ''
+    end
+  },
   -- Extracts table value from key-value list
   ['elt'] = {
     ['types'] = {