Diff

spec/util_format_spec.lua @ 12032:3db09eb4c43b

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.
author Kim Alvefur <zash@zash.se>
date Sat, 11 Dec 2021 13:30:34 +0100
parent 12031:87bc26f23d9b
child 12033:161f8268c4b3
line wrap: on
line diff
--- a/spec/util_format_spec.lua	Fri Dec 10 22:48:45 2021 +0100
+++ b/spec/util_format_spec.lua	Sat Dec 11 13:30:34 2021 +0100
@@ -18,6 +18,7 @@
 
 		it("escapes ascii control stuff", function ()
 			assert.equal("␁", format("%s", "\1"));
+			assert.equal("[␁]", format("%d", "\1"));
 		end);
 
 		it("escapes invalid UTF-8", function ()