diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-06 12:39:21 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-06 12:39:21 +0100 |
commit | 5aed65dc5cd6ac78f39e1c4ff4e9471ab434181e (patch) | |
tree | b082fd3482288951de2e8d4837ca88732963811e /lualib/lua_magic/init.lua | |
parent | 786faec3794563dd8a1fb503695d50797cc2bffa (diff) | |
download | rspamd-5aed65dc5cd6ac78f39e1c4ff4e9471ab434181e.tar.gz rspamd-5aed65dc5cd6ac78f39e1c4ff4e9471ab434181e.zip |
[Project] Lua_magic: Support hex patterns
Diffstat (limited to 'lualib/lua_magic/init.lua')
-rw-r--r-- | lualib/lua_magic/init.lua | 10 |
1 files changed, 10 insertions, 0 deletions
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 |