Comparison

util/format.lua @ 12220:25b853e64d83

util.format: Skip control code escaping when doing full serialization Fixes that a multi-line string ended up "like\ \9this" instead of "like\nthis" as can be demonstrated by somehow initiating a connection to a HTTP server.
author Kim Alvefur <zash@zash.se>
date Thu, 27 Jan 2022 21:14:22 +0100
parent 12040:337b489532b7
child 12221:056b7920b686
comparison
equal deleted inserted replaced
12219:0a44def211fa 12220:25b853e64d83
106 end 106 end
107 107
108 if t == "string" and option ~= "p" then 108 if t == "string" and option ~= "p" then
109 if not valid_utf8(arg) then 109 if not valid_utf8(arg) then
110 option = "q"; 110 option = "q";
111 else 111 elseif option ~= "q" then -- gets fully escaped in the next block
112 args[i] = arg:gsub("[%z\1-\8\11-\31\127]", control_symbols):gsub("\n\t?", "\n\t"); 112 args[i] = arg:gsub("[%z\1-\8\11-\31\127]", control_symbols):gsub("\n\t?", "\n\t");
113 return spec; 113 return spec;
114 end 114 end
115 end 115 end
116 116