Diff

mod_firewall/conditions.lib.lua @ 2109:9db4113d0cb5

mod_firewall: INSPECT: Support for pattern matches (confusingly using ~= instead of =)
author Matthew Wild <mwild1@gmail.com>
date Thu, 17 Mar 2016 11:37:19 +0000
parent 2107:f445f43b9ba1
child 2116:2bb42ba342f3
line wrap: on
line diff
--- a/mod_firewall/conditions.lib.lua	Thu Mar 17 11:33:57 2016 +0000
+++ b/mod_firewall/conditions.lib.lua	Thu Mar 17 11:37:19 2016 +0000
@@ -95,7 +95,12 @@
 
 function condition_handlers.INSPECT(path)
 	if path:find("=") then
-		return ("stanza:find(%q) == %q"):format(path:match("(.-)=(.*)"));
+		local query, is_pattern_match, value = path:match("(.-)(~?)=(.*)");
+		if is_pattern_match ~= "" then
+			return ("stanza:find(%q):match(%q)"):format(path:match("(.-)~=(.*)"));
+		else
+			return ("stanza:find(%q) == %q"):format(path:match("(.-)=(.*)"));
+		end
 	end
 	return ("stanza:find(%q)"):format(path);
 end