From: Vsevolod Stakhov Date: Fri, 6 Sep 2019 11:39:21 +0000 (+0100) Subject: [Project] Lua_magic: Support hex patterns X-Git-Tag: 2.0~268 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5aed65dc5cd6ac78f39e1c4ff4e9471ab434181e;p=rspamd.git [Project] Lua_magic: Support hex patterns --- diff --git a/lualib/lua_magic/init.lua b/lualib/lua_magic/init.lua index e8629eeda..1ba899b06 100644 --- a/lualib/lua_magic/init.lua +++ b/lualib/lua_magic/init.lua @@ -42,6 +42,16 @@ local function process_patterns() processed_patterns[#processed_patterns + 1] = { match.string, match, pattern } + elseif match.hex then + local hex_table = {} + + for i=1,#match.hex,2 do + local subc = match.hex:sub(i, i + 1) + hex_table[#hex_table + 1] = string.format('\\x{%s}', subc) + end + processed_patterns[#processed_patterns + 1] = { + table.concat(hex_table), match, pattern + } end end end