From 1eca4e8870f69699f7bc9bbd132a7bf64ca70918 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 11 Dec 2021 13:30:34 +0100 Subject: 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. --- spec/util_format_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'spec') 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 () -- cgit v1.2.3