aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_format_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-11 13:30:34 +0100
committerKim Alvefur <zash@zash.se>2021-12-11 13:30:34 +0100
commit1eca4e8870f69699f7bc9bbd132a7bf64ca70918 (patch)
treef46fbc10f5c88e0a0468b41f9dc5718b5a7e9aec /spec/util_format_spec.lua
parentd4c145179420e6de0d2189059ea988072a7e7e45 (diff)
downloadprosody-1eca4e8870f69699f7bc9bbd132a7bf64ca70918.tar.gz
prosody-1eca4e8870f69699f7bc9bbd132a7bf64ca70918.zip
util.format: Ensure sanitation of strings passed to wrong format
Ie. log("debug", "%d", "\1\2\3") should not result in garbage. Also optimizing for the common case of ASCII string passed to %s and early returns everywhere. Returning nil from a gsub callback keeps the original substring.
Diffstat (limited to 'spec/util_format_spec.lua')
-rw-r--r--spec/util_format_spec.lua1
1 files changed, 1 insertions, 0 deletions
diff --git a/spec/util_format_spec.lua b/spec/util_format_spec.lua
index 8d6ba8ad..0e6a36b7 100644
--- a/spec/util_format_spec.lua
+++ b/spec/util_format_spec.lua
@@ -18,6 +18,7 @@ describe("util.format", function()
it("escapes ascii control stuff", function ()
assert.equal("␁", format("%s", "\1"));
+ assert.equal("[␁]", format("%d", "\1"));
end);
it("escapes invalid UTF-8", function ()