summaryrefslogtreecommitdiff
path: root/ext/console/01_colors.js
diff options
context:
space:
mode:
authorKenta Moriuchi <moriken@kimamass.com>2023-03-01 08:14:16 +0900
committerGitHub <noreply@github.com>2023-03-01 08:14:16 +0900
commit55833cf799979e63c6b027fbbf018272308caf5c (patch)
treecc0ae9aa9116e6296e5e74e1c926cfd94fa26449 /ext/console/01_colors.js
parent6ffbf8a9410f5ea41669efdece60f7f47f77e3c7 (diff)
fix(core): introduce `SafeRegExp` to primordials (#17592)
Diffstat (limited to 'ext/console/01_colors.js')
-rw-r--r--ext/console/01_colors.js6
1 files changed, 3 insertions, 3 deletions
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=><~]))",