Mercurial > prosody-modules
comparison mod_firewall/conditions.lib.lua @ 2362:c065ab67d807
mod_firewall: INSPECT: Emit compilation error when the given stanza path is used for comparison but doesn't return a string
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 15 Nov 2016 14:57:40 +0000 |
| parents | 6848297cf40a |
| children | 12b78170b76c |
comparison
equal
deleted
inserted
replaced
| 2361:231d47e61c81 | 2362:c065ab67d807 |
|---|---|
| 110 end | 110 end |
| 111 | 111 |
| 112 function condition_handlers.INSPECT(path) | 112 function condition_handlers.INSPECT(path) |
| 113 if path:find("=") then | 113 if path:find("=") then |
| 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 | |
| 116 error("Stanza path does not return a string (append # for text content or @name for value of named attribute)", 0); | |
| 117 end | |
| 115 if is_pattern_match ~= "" then | 118 if is_pattern_match ~= "" then |
| 116 return ("stanza:find(%q):match(%q)"):format(path:match("(.-)~=(.*)")); | 119 return ("stanza:find(%q):match(%q)"):format(path:match("(.-)~=(.*)")); |
| 117 else | 120 else |
| 118 return ("stanza:find(%q) == %q"):format(path:match("(.-)=(.*)")); | 121 return ("stanza:find(%q) == %q"):format(path:match("(.-)=(.*)")); |
| 119 end | 122 end |
