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 /ext/web/09_file.js | |
| parent | 6ffbf8a9410f5ea41669efdece60f7f47f77e3c7 (diff) | |
fix(core): introduce `SafeRegExp` to primordials (#17592)
Diffstat (limited to 'ext/web/09_file.js')
| -rw-r--r-- | ext/web/09_file.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/web/09_file.js b/ext/web/09_file.js index b44537dd4..c2fe7782c 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -29,6 +29,7 @@ const { RegExpPrototypeTest, // TODO(lucacasonato): add SharedArrayBuffer to primordials // SharedArrayBufferPrototype + SafeRegExp, StringPrototypeCharAt, StringPrototypeToLowerCase, StringPrototypeSlice, @@ -143,13 +144,15 @@ function processBlobParts(parts, endings) { return { parts: processedParts, size }; } +const NORMALIZE_PATTERN = new SafeRegExp(/^[\x20-\x7E]*$/); + /** * @param {string} str * @returns {string} */ function normalizeType(str) { let normalizedType = str; - if (!RegExpPrototypeTest(/^[\x20-\x7E]*$/, str)) { + if (!RegExpPrototypeTest(NORMALIZE_PATTERN, str)) { normalizedType = ""; } return StringPrototypeToLowerCase(normalizedType); |
