Mercurial > prosody-modules
comparison mod_firewall/conditions.lib.lua @ 2363:12b78170b76c
mod_firewall: INSPECT: Handle stanza:find() returning nil (i.e. path didn't match)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 15 Nov 2016 14:58:16 +0000 |
parents | c065ab67d807 |
children | 00eed68f63bf |
comparison
equal
deleted
inserted
replaced
2362:c065ab67d807 | 2363:12b78170b76c |
---|---|
114 local query, is_pattern_match, value = path:match("(.-)(~?)=(.*)"); | 114 local query, is_pattern_match, value = path:match("(.-)(~?)=(.*)"); |
115 if not(query:match("#$") or query:match("@[^/]+")) then | 115 if not(query:match("#$") or query:match("@[^/]+")) then |
116 error("Stanza path does not return a string (append # for text content or @name for value of named attribute)", 0); | 116 error("Stanza path does not return a string (append # for text content or @name for value of named attribute)", 0); |
117 end | 117 end |
118 if is_pattern_match ~= "" then | 118 if is_pattern_match ~= "" then |
119 return ("stanza:find(%q):match(%q)"):format(path:match("(.-)~=(.*)")); | 119 return ("(stanza:find(%q) or ''):match(%q)"):format(path:match("(.-)~=(.*)")); |
120 else | 120 else |
121 return ("stanza:find(%q) == %q"):format(path:match("(.-)=(.*)")); | 121 return ("stanza:find(%q) == %q"):format(path:match("(.-)=(.*)")); |
122 end | 122 end |
123 end | 123 end |
124 return ("stanza:find(%q)"):format(path); | 124 return ("stanza:find(%q)"):format(path); |