Software /
code /
prosody-modules
Comparison
mod_firewall/mod_firewall.lua @ 2538:a1b6a6b0aabb
mod_firewall: Reinstate the ability to set a default for stanza expressions
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 21 Feb 2017 10:37:53 +0000 |
parent | 2533:9aed7f4e9f07 |
child | 2539:1510b66a43fc |
comparison
equal
deleted
inserted
replaced
2537:acdc1767a715 | 2538:a1b6a6b0aabb |
---|---|
68 expr = expr:gsub("\\(.)", "%1"); | 68 expr = expr:gsub("\\(.)", "%1"); |
69 return [["..tostring(]]..expr..[[).."]]; | 69 return [["..tostring(]]..expr..[[).."]]; |
70 end) | 70 end) |
71 :gsub("$(%b<>)", function (expr) | 71 :gsub("$(%b<>)", function (expr) |
72 expr = expr:sub(2,-2); | 72 expr = expr:sub(2,-2); |
73 local default = "<undefined>"; | |
74 expr = expr:gsub("||(%b\"\")$", function (s) | |
75 default = s:sub(2,-2); | |
76 return ""; | |
77 end); | |
73 local func_chain = expr:match("|[%w|]+$"); | 78 local func_chain = expr:match("|[%w|]+$"); |
74 if func_chain then | 79 if func_chain then |
75 expr = expr:sub(1, -1-#func_chain); | 80 expr = expr:sub(1, -1-#func_chain); |
76 end | 81 end |
77 local code; | 82 local code; |
111 end | 116 end |
112 end | 117 end |
113 end | 118 end |
114 end | 119 end |
115 end | 120 end |
116 return "\"..tostring(("..code..") or \"<undefined>\")..\""; | 121 return "\"..tostring("..code.." or "..("%q"):format(default)..")..\""; |
117 end) | 122 end) |
118 :gsub("$$(%a+)", extra or {}) | 123 :gsub("$$(%a+)", extra or {}) |
119 :gsub([[^""%.%.]], "") | 124 :gsub([[^""%.%.]], "") |
120 :gsub([[%.%.""$]], "")); | 125 :gsub([[%.%.""$]], "")); |
121 end | 126 end |
122 | |
123 | 127 |
124 -- Dependency locations: | 128 -- Dependency locations: |
125 -- <type lib> | 129 -- <type lib> |
126 -- <type global> | 130 -- <type global> |
127 -- function handler() | 131 -- function handler() |