changeset 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
parents 573fe9825fba
children c26b28c65d47
files mod_firewall/conditions.lib.lua
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
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