From 55833cf799979e63c6b027fbbf018272308caf5c Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Wed, 1 Mar 2023 08:14:16 +0900 Subject: fix(core): introduce `SafeRegExp` to primordials (#17592) --- ext/console/01_colors.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ext/console/01_colors.js') diff --git a/ext/console/01_colors.js b/ext/console/01_colors.js index d01edd247..a598db921 100644 --- a/ext/console/01_colors.js +++ b/ext/console/01_colors.js @@ -4,7 +4,7 @@ const primordials = globalThis.__bootstrap.primordials; const { - RegExp, + SafeRegExp, StringPrototypeReplace, ArrayPrototypeJoin, } = primordials; @@ -23,7 +23,7 @@ function code(open, close) { return { open: `\x1b[${open}m`, close: `\x1b[${close}m`, - regexp: new RegExp(`\\x1b\\[${close}m`, "g"), + regexp: new SafeRegExp(`\\x1b\\[${close}m`, "g"), }; } @@ -74,7 +74,7 @@ function magenta(str) { } // https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js -const ANSI_PATTERN = new RegExp( +const ANSI_PATTERN = new SafeRegExp( ArrayPrototypeJoin([ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))", -- cgit v1.2.3