Mercurial > prosody-modules
comparison mod_firewall/conditions.lib.lua @ 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 | f445f43b9ba1 |
| children | 2bb42ba342f3 |
comparison
equal
deleted
inserted
replaced
| 2108:573fe9825fba | 2109:9db4113d0cb5 |
|---|---|
| 93 return ("stanza:get_child(nil, %q)"):format(payload_ns); | 93 return ("stanza:get_child(nil, %q)"):format(payload_ns); |
| 94 end | 94 end |
| 95 | 95 |
| 96 function condition_handlers.INSPECT(path) | 96 function condition_handlers.INSPECT(path) |
| 97 if path:find("=") then | 97 if path:find("=") then |
| 98 return ("stanza:find(%q) == %q"):format(path:match("(.-)=(.*)")); | 98 local query, is_pattern_match, value = path:match("(.-)(~?)=(.*)"); |
| 99 if is_pattern_match ~= "" then | |
| 100 return ("stanza:find(%q):match(%q)"):format(path:match("(.-)~=(.*)")); | |
| 101 else | |
| 102 return ("stanza:find(%q) == %q"):format(path:match("(.-)=(.*)")); | |
| 103 end | |
| 99 end | 104 end |
| 100 return ("stanza:find(%q)"):format(path); | 105 return ("stanza:find(%q)"):format(path); |
| 101 end | 106 end |
| 102 | 107 |
| 103 function condition_handlers.FROM_GROUP(group_name) | 108 function condition_handlers.FROM_GROUP(group_name) |
