comparison mod_firewall/mod_firewall.lua @ 2524:0404476ecfe3

mod_firewall: More meta() enhancements
author Matthew Wild <mwild1@gmail.com>
date Mon, 20 Feb 2017 09:28:35 +0000
parents c6fd8975704b
children a35d85cfda92
comparison
equal deleted inserted replaced
2523:a3a18d09ae8a 2524:0404476ecfe3
83 code = attr_name; 83 code = attr_name;
84 table.insert(deps, attr_name); 84 table.insert(deps, attr_name);
85 else 85 else
86 code = "stanza.attr["..("%q"):format(attr_name).."]"; 86 code = "stanza.attr["..("%q"):format(attr_name).."]";
87 end 87 end
88 elseif expr:match("^%w+#$") then
89 code = ("stanza:get_child_text(%q)"):format(expr:sub(1, -2));
88 else 90 else
89 code = "(stanza:find("..("%q"):format(expr)..") or "..("%q"):format("<undefined>")..")"; 91 code = ("stanza:find(%q)"):format(expr);
90 end 92 end
91 if func_chain then 93 if func_chain then
92 for func_name in func_chain:gmatch("|(%w+)") do 94 for func_name in func_chain:gmatch("|(%w+)") do
93 if code == "to" or code == "from" then 95 if code == "to" or code == "from" then
94 if func_name == "bare" then 96 if func_name == "bare" then
109 end 111 end
110 end 112 end
111 end 113 end
112 end 114 end
113 end 115 end
114 return "\"..(("..code..") or \"<undefined>\")..\""; 116 return "\"..tostring(("..code..") or \"<undefined>\")..\"";
115 end) 117 end)
116 :gsub("$$(%a+)", extra or {}) 118 :gsub("$$(%a+)", extra or {})
117 :gsub([[^""%.%.]], "") 119 :gsub([[^""%.%.]], "")
118 :gsub([[%.%.""$]], "")); 120 :gsub([[%.%.""$]], ""));
119 end 121 end