fix: sanitize Windows CI output safely (#569) (thanks @bjesuiter)

This commit is contained in:
Peter Steinberger 2026-01-09 14:20:53 +01:00
parent 22b224a343
commit bd6e881eba

View File

@ -6,8 +6,22 @@ const shouldSanitizeConsoleOutput =
process.platform === "win32" && process.env.GITHUB_ACTIONS === "true";
if (shouldSanitizeConsoleOutput) {
const sanitize = (value: string) =>
value.replace(/[^\x09\x0A\x0D\x20-\x7E]/g, "?");
const sanitize = (value: string) => {
let out = "";
for (const ch of value) {
const code = ch.charCodeAt(0);
if (code === 9 || code === 10 || code === 13) {
out += ch;
continue;
}
if (code >= 32 && code <= 126) {
out += ch;
continue;
}
out += "?";
}
return out;
};
const patchStream = (stream: NodeJS.WriteStream) => {
const originalWrite = stream.write.bind(stream);