diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-03-01 08:14:16 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 08:14:16 +0900 |
commit | 55833cf799979e63c6b027fbbf018272308caf5c (patch) | |
tree | cc0ae9aa9116e6296e5e74e1c926cfd94fa26449 /runtime/js/06_util.js | |
parent | 6ffbf8a9410f5ea41669efdece60f7f47f77e3c7 (diff) |
fix(core): introduce `SafeRegExp` to primordials (#17592)
Diffstat (limited to 'runtime/js/06_util.js')
-rw-r--r-- | runtime/js/06_util.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/runtime/js/06_util.js b/runtime/js/06_util.js index 435a55a61..c9bd86285 100644 --- a/runtime/js/06_util.js +++ b/runtime/js/06_util.js @@ -7,6 +7,7 @@ const { ObjectPrototypeIsPrototypeOf, Promise, SafeArrayIterator, + SafeRegExp, StringPrototypeReplace, TypeError, } = primordials; @@ -49,7 +50,7 @@ function createResolvable() { function pathFromURLWin32(url) { let p = StringPrototypeReplace( url.pathname, - /^\/*([A-Za-z]:)(\/|$)/, + new SafeRegExp(/^\/*([A-Za-z]:)(\/|$)/), "$1/", ); p = StringPrototypeReplace( @@ -59,7 +60,7 @@ function pathFromURLWin32(url) { ); p = StringPrototypeReplace( p, - /%(?![0-9A-Fa-f]{2})/g, + new SafeRegExp(/%(?![0-9A-Fa-f]{2})/g), "%25", ); let path = decodeURIComponent(p); @@ -79,7 +80,11 @@ function pathFromURLPosix(url) { } return decodeURIComponent( - StringPrototypeReplace(url.pathname, /%(?![0-9A-Fa-f]{2})/g, "%25"), + StringPrototypeReplace( + url.pathname, + new SafeRegExp(/%(?![0-9A-Fa-f]{2})/g), + "%25", + ), ); } |