# HG changeset patch # User Matthew Wild # Date 1365185853 -3600 # Node ID 93ffa3ffc66f3011a4d668729fdd68ee8ddcd834 # Parent f0108ec2b0162a3099acee6d914a4775dbb10a50 mod_firewall/conditions: Support Lua patterns in JID matching, and make <*>@example.com NOT match example.com diff -r f0108ec2b016 -r 93ffa3ffc66f mod_firewall/conditions.lib.lua --- a/mod_firewall/conditions.lib.lua Fri Apr 05 18:50:52 2013 +0100 +++ b/mod_firewall/conditions.lib.lua Fri Apr 05 19:17:33 2013 +0100 @@ -24,11 +24,16 @@ return part.." == nil" end local pattern = match:match("<(.*)>"); - -- TODO: Support Lua pattern matching (main issue syntax... << >>?) if pattern then - if pattern ~= "*" then - return ("%s:match(%q)"):format(part, pattern:gsub(".", wildcard_equivs)); + if pattern == "*" then + return part; end + if pattern:match("^<.*>$") then + pattern = pattern:match("^<(.*)>$"); + else + pattern = pattern:gsub("%p", "%%%0"):gsub("%%(%p)", wildcard_equivs); + end + return ("%s:match(%q)"):format(part, "^"..pattern.."$"); else return ("%s == %q"):format(part, match); end