aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-10-20 20:52:14 +0200
committerKim Alvefur <zash@zash.se>2019-10-20 20:52:14 +0200
commit01c5fd53fb6ba95990d046abb5b9cdfae00915b4 (patch)
treecdfe1a2affe77713df6acdbe3f6dadc43f160e89 /util
parent3e484e457e313e983d6482a0cac01ea30bb9ad26 (diff)
downloadprosody-01c5fd53fb6ba95990d046abb5b9cdfae00915b4.tar.gz
prosody-01c5fd53fb6ba95990d046abb5b9cdfae00915b4.zip
util.interpolation: Support unescaped variables with more modifiers (fixes #1452)
Tests will be added in trunk.
Diffstat (limited to 'util')
-rw-r--r--util/interpolation.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/util/interpolation.lua b/util/interpolation.lua
index 315cc203..e0ccf47b 100644
--- a/util/interpolation.lua
+++ b/util/interpolation.lua
@@ -32,7 +32,7 @@ local function new_render(pat, escape, funcs)
-- assert(type(values) == "table", "bad argument #2 to 'render' (table expected)");
return (s_gsub(template, pat, function (block)
block = s_sub(block, 2, -2);
- local name, opt, e = s_match(block, "^([%a_][%w_.]*)(%p?)()");
+ local name, raw, opt, e = s_match(block, "^([%a_][%w_.]*)(!?)(%p?)()");
if not name then return end
local value = values[name];
if not value and name:find(".", 2, true) then
@@ -45,7 +45,7 @@ local function new_render(pat, escape, funcs)
if funcs then
while value ~= nil and opt == '|' do
local f;
- f, opt, e = s_match(block, "^([%a_][%w_.]*)(%p?)()", e);
+ f, raw, opt, e = s_match(block, "^([%a_][%w_.]*)(!?)(%p?)()", e);
f = funcs[f];
if f then value = f(value); end
end
@@ -70,7 +70,7 @@ local function new_render(pat, escape, funcs)
if type(value) ~= "string" then
value = tostring(value);
end
- if opt ~= '!' then
+ if raw ~= '!' then
return escape(value);
end
return value;