From bd6e881ebafa60cf1725da4cb1587bee9aa15164 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 14:20:53 +0100 Subject: [PATCH] fix: sanitize Windows CI output safely (#569) (thanks @bjesuiter) --- test/setup.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/setup.ts b/test/setup.ts index 63490725a..22c9627d6 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -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);