comparison mod_firewall/actions.lib.lua @ 2125:edf5cf3c474b

mod_firewall: Move meta() function to main module, and make it a global so libs can use it
author Matthew Wild <mwild1@gmail.com>
date Thu, 17 Mar 2016 21:29:07 +0000
parents f445f43b9ba1
children 26334f4a8eb9
comparison
equal deleted inserted replaced
2124:89363766202c 2125:edf5cf3c474b
1 --luacheck: globals meta idsafe
1 local action_handlers = {}; 2 local action_handlers = {};
2 3
3
4 -- Run code through this to allow strings to contain code. e.g.: LOG=Received: $(stanza:top_tag())
5 local function meta(s, extra)
6 return (s:gsub("$(%b())", [["..tostring(%1).."]])
7 :gsub("$(%b<>)", [["..stanza:find("%1").."]])
8 :gsub("$$(%a+)", extra or {}));
9 end
10 4
11 -- Takes an XML string and returns a code string that builds that stanza 5 -- Takes an XML string and returns a code string that builds that stanza
12 -- using st.stanza() 6 -- using st.stanza()
13 local function compile_xml(data) 7 local function compile_xml(data)
14 local code = {}; 8 local code = {};