Comparison

util/format.lua @ 11647:0fe6a9a3676f

util.format: Allow newlines but ensure following lines are indented This should a) prevent injection of text that looks like legitimate log lines and b) not mangle tracebacks.
author Kim Alvefur <zash@zash.se>
date Sat, 03 Jul 2021 04:29:25 +0200
parent 11646:b6ea0148ad37
child 11648:96d3cbeb9275
comparison
equal deleted inserted replaced
11646:b6ea0148ad37 11647:0fe6a9a3676f
58 spec = "(%s)"; 58 spec = "(%s)";
59 elseif option == "q" then 59 elseif option == "q" then
60 args[i] = dump(arg); 60 args[i] = dump(arg);
61 spec = "%s"; 61 spec = "%s";
62 elseif option == "s" then 62 elseif option == "s" then
63 args[i] = tostring(arg):gsub("[%z\1-\31\127]", control_symbols); 63 args[i] = tostring(arg):gsub("[%z\1-\8\11-\31\127]", control_symbols):gsub("\n\t?", "\n\t");
64 elseif type(arg) ~= "number" then -- arg isn't number as expected? 64 elseif type(arg) ~= "number" then -- arg isn't number as expected?
65 args[i] = tostring(arg); 65 args[i] = tostring(arg);
66 spec = "[%s]"; 66 spec = "[%s]";
67 elseif expects_integer[option] and num_type(arg) ~= "integer" then 67 elseif expects_integer[option] and num_type(arg) ~= "integer" then
68 args[i] = tostring(arg); 68 args[i] = tostring(arg);