]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Selectors: Add equal processor
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 11 Dec 2018 20:05:25 +0000 (20:05 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 11 Dec 2018 20:05:25 +0000 (20:05 +0000)
lualib/lua_selectors.lua

index cc137bddd8d2f730efbcb5cc532dd1090168db80..8d68341b47932201d1f2c90f998301375c8fb0c4 100644 (file)
@@ -497,6 +497,22 @@ the second argument is optional hash type (`blake2`, `sha256`, `sha1`, `sha512`,
     ['description'] = 'Drops input value and return values from function\'s arguments or an empty string',
     ['args_schema'] = (ts.string + ts.array_of(ts.string)):is_optional()
   },
+  ['equal'] = {
+    ['types'] = {
+      ['string'] = true,
+    },
+    ['map_type'] = 'string',
+    ['process'] = function(inp, _, args)
+      if inp == args[1] then
+        return inp,'string'
+      end
+
+      return nil
+    end,
+    ['description'] = [[Boolean function equal.
+Returns either nil or its argument if input is equal to argument]],
+    ['args_schema'] = {ts.string}
+  },
   -- Boolean function in, returns either nil or its input if input is in args list
   ['in'] = {
     ['types'] = {