mod_firewall: Don't add empty conditions check when no conditions are listed in a rule
authorMatthew Wild <mwild1@gmail.com>
Sat, 06 Apr 2013 14:03:02 +0100
changeset 967 a88f33fe6970
parent 966 a65df6e97d94
child 968 f3b0ddeebd9d
mod_firewall: Don't add empty conditions check when no conditions are listed in a rule
mod_firewall/mod_firewall.lua
--- a/mod_firewall/mod_firewall.lua	Sat Apr 06 14:02:38 2013 +0100
+++ b/mod_firewall/mod_firewall.lua	Sat Apr 06 14:03:02 2013 +0100
@@ -256,9 +256,12 @@
 			for _, dep in ipairs(rule.deps) do
 				include_dep(dep, code);
 			end
-			local rule_code = "if ("..table.concat(rule.conditions, ") and (")..") then\n\t"
-			..table.concat(rule.actions, "\n\t")
-			.."\n end\n";
+			local rule_code = table.concat(rule.actions, "\n\t");
+			if #rule.conditions > 0 then
+				rule_code = "if ("..table.concat(rule.conditions, ") and (")..") then\n\t"
+				..rule_code
+				.."\n end\n";
+			end
 			table.insert(code, rule_code);
 		end