Diff

mod_firewall/mod_firewall.lua @ 2385:c0c2f8665c3e

mod_firewall: Fix for raw code expressions that contain escape-worthy characters
author Matthew Wild <mwild1@gmail.com>
date Sat, 19 Nov 2016 15:47:41 +0000
parent 2374:d630fa0d4dba
child 2402:2040330586e4
line wrap: on
line diff
--- a/mod_firewall/mod_firewall.lua	Sat Nov 19 19:40:29 2016 +0100
+++ b/mod_firewall/mod_firewall.lua	Sat Nov 19 15:47:41 2016 +0000
@@ -49,7 +49,10 @@
 
 -- Run quoted (%q) strings through this to allow them to contain code. e.g.: LOG=Received: $(stanza:top_tag())
 function meta(s, extra)
-	return (s:gsub("$(%b())", [["..tostring(%1).."]])
+	return (s:gsub("$(%b())", function (expr)
+			expr = expr:gsub("\\(.)", "%1");
+			return [["..tostring(]]..expr..[[).."]];
+		end)
 		:gsub("$(%b<>)", function (expr)
 			expr = expr:sub(2,-2);
 			local default = expr:match("||([^|]+)$");