# HG changeset patch # User Kim Alvefur # Date 1625279365 -7200 # Node ID 0fe6a9a3676f3419257b78cd7cad2731227df81d # Parent b6ea0148ad37a23f388719bf8ac4893f8b886235 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. diff -r b6ea0148ad37 -r 0fe6a9a3676f util/format.lua --- a/util/format.lua Sat Jul 03 04:24:13 2021 +0200 +++ b/util/format.lua Sat Jul 03 04:29:25 2021 +0200 @@ -60,7 +60,7 @@ args[i] = dump(arg); spec = "%s"; elseif option == "s" then - args[i] = tostring(arg):gsub("[%z\1-\31\127]", control_symbols); + args[i] = tostring(arg):gsub("[%z\1-\8\11-\31\127]", control_symbols):gsub("\n\t?", "\n\t"); elseif type(arg) ~= "number" then -- arg isn't number as expected? args[i] = tostring(arg); spec = "[%s]";