diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-04-15 05:23:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 22:23:28 +0200 |
commit | f086ec57b453fc0af763564eb80fea4b5b7f7296 (patch) | |
tree | 8c7800d918751893e4011eb86f23e8f687d4139b /ext/fetch | |
parent | 136dce67cec749dce5989ea29e88359ef79a0045 (diff) |
fix(core): Use safe primordials wrappers (#18687)
Diffstat (limited to 'ext/fetch')
-rw-r--r-- | ext/fetch/21_formdata.js | 8 | ||||
-rw-r--r-- | ext/fetch/26_fetch.js | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/ext/fetch/21_formdata.js b/ext/fetch/21_formdata.js index 92c914b8c..1961643d2 100644 --- a/ext/fetch/21_formdata.js +++ b/ext/fetch/21_formdata.js @@ -22,12 +22,12 @@ const { ArrayPrototypePush, ArrayPrototypeSlice, ArrayPrototypeSplice, - Map, MapPrototypeGet, MapPrototypeSet, MathRandom, ObjectFreeze, ObjectPrototypeIsPrototypeOf, + SafeMap, SafeRegExp, Symbol, StringFromCharCode, @@ -346,13 +346,15 @@ function formDataToBlob(formData) { }); } +const QUOTE_CONTENT_PATTERN = new SafeRegExp(/^"([^"]*)"$/); + /** * @param {string} value * @returns {Map<string, string>} */ function parseContentDisposition(value) { /** @type {Map<string, string>} */ - const params = new Map(); + const params = new SafeMap(); // Forced to do so for some Map constructor param mismatch const values = ArrayPrototypeSlice(StringPrototypeSplit(value, ";"), 1); for (let i = 0; i < values.length; i++) { @@ -361,7 +363,7 @@ function parseContentDisposition(value) { MapPrototypeSet( params, entries[0], - StringPrototypeReplace(entries[1], /^"([^"]*)"$/, "$1"), + StringPrototypeReplace(entries[1], QUOTE_CONTENT_PATTERN, "$1"), ); } } diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 18cb47a59..42e1ae962 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -42,13 +42,13 @@ const { PromisePrototypeThen, PromisePrototypeCatch, SafeArrayIterator, + SafeWeakMap, String, StringPrototypeStartsWith, StringPrototypeToLowerCase, TypeError, Uint8Array, Uint8ArrayPrototype, - WeakMap, WeakMapPrototypeDelete, WeakMapPrototypeGet, WeakMapPrototypeHas, @@ -62,7 +62,7 @@ const REQUEST_BODY_HEADER_NAMES = [ "content-type", ]; -const requestBodyReaders = new WeakMap(); +const requestBodyReaders = new SafeWeakMap(); /** * @param {{ method: string, url: string, headers: [string, string][], clientRid: number | null, hasBody: boolean }} args |