mod_firewall: INSPECT: Emit compilation error when the given stanza path is used for comparison but doesn't return a string
authorMatthew Wild <mwild1@gmail.com>
Tue, 15 Nov 2016 14:57:40 +0000
changeset 2366 c065ab67d807
parent 2365 231d47e61c81
child 2367 12b78170b76c
mod_firewall: INSPECT: Emit compilation error when the given stanza path is used for comparison but doesn't return a string
mod_firewall/conditions.lib.lua
--- a/mod_firewall/conditions.lib.lua	Tue Nov 15 09:01:03 2016 +0100
+++ b/mod_firewall/conditions.lib.lua	Tue Nov 15 14:57:40 2016 +0000
@@ -112,6 +112,9 @@
 function condition_handlers.INSPECT(path)
 	if path:find("=") then
 		local query, is_pattern_match, value = path:match("(.-)(~?)=(.*)");
+		if not(query:match("#$") or query:match("@[^/]+")) then
+			error("Stanza path does not return a string (append # for text content or @name for value of named attribute)", 0);
+		end
 		if is_pattern_match ~= "" then
 			return ("stanza:find(%q):match(%q)"):format(path:match("(.-)~=(.*)"));
 		else