From 8779ad7f98388b5136c23aa61bfc82afbc4598f8 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Feb 2026 13:12:17 +0100 Subject: [PATCH] chore(lint): avoid control regex in download sanitizer --- src/browser/pw-tools-core.downloads.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/browser/pw-tools-core.downloads.ts b/src/browser/pw-tools-core.downloads.ts index d551b21f723..0a242082927 100644 --- a/src/browser/pw-tools-core.downloads.ts +++ b/src/browser/pw-tools-core.downloads.ts @@ -28,7 +28,15 @@ function sanitizeDownloadFileName(fileName: string): string { // path separators/traversal can't escape the downloads dir on any platform. let base = path.posix.basename(trimmed); base = path.win32.basename(base); - base = base.replace(/[\u0000-\u001f\u007f]/g, "").trim(); + let cleaned = ""; + for (let i = 0; i < base.length; i++) { + const code = base.charCodeAt(i); + if (code < 0x20 || code === 0x7f) { + continue; + } + cleaned += base[i]; + } + base = cleaned.trim(); if (!base || base === "." || base === "..") { return "download.bin";