diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-02-07 13:54:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-07 13:54:32 +0100 |
commit | bf22f114a6e049744866ebaba48faec2cb86549b (patch) | |
tree | ea6814e51bade2355144546f21178f54811a57f2 /ext/fetch | |
parent | 9c7ed1c98b75c3557ac9e269212dcf655f69c0a2 (diff) |
refactor: update runtime code for primordial check for iterators (#13510)
Diffstat (limited to 'ext/fetch')
-rw-r--r-- | ext/fetch/20_headers.js | 6 | ||||
-rw-r--r-- | ext/fetch/23_request.js | 5 | ||||
-rw-r--r-- | ext/fetch/23_response.js | 13 | ||||
-rw-r--r-- | ext/fetch/26_fetch.js | 5 |
4 files changed, 22 insertions, 7 deletions
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index 94f68df42..e8a658d67 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -32,6 +32,7 @@ ObjectPrototypeHasOwnProperty, ObjectEntries, RegExpPrototypeTest, + SafeArrayIterator, Symbol, SymbolFor, SymbolIterator, @@ -230,7 +231,10 @@ } return ArrayPrototypeSort( - [...ObjectEntries(headers), ...cookies], + [ + ...new SafeArrayIterator(ObjectEntries(headers)), + ...new SafeArrayIterator(cookies), + ], (a, b) => { const akey = a[0]; const bkey = b[0]; diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js index 5294009ff..1ffdd2a60 100644 --- a/ext/fetch/23_request.js +++ b/ext/fetch/23_request.js @@ -38,6 +38,7 @@ ObjectKeys, ObjectPrototypeIsPrototypeOf, RegExpPrototypeTest, + SafeArrayIterator, Symbol, SymbolFor, TypeError, @@ -101,7 +102,9 @@ */ function cloneInnerRequest(request) { const headerList = [ - ...ArrayPrototypeMap(request.headerList, (x) => [x[0], x[1]]), + ...new SafeArrayIterator( + ArrayPrototypeMap(request.headerList, (x) => [x[0], x[1]]), + ), ]; let body = null; if (request.body !== null) { diff --git a/ext/fetch/23_response.js b/ext/fetch/23_response.js index 14aadbaf2..4dc56dd8f 100644 --- a/ext/fetch/23_response.js +++ b/ext/fetch/23_response.js @@ -37,6 +37,7 @@ RangeError, RegExp, RegExpPrototypeTest, + SafeArrayIterator, Symbol, SymbolFor, TypeError, @@ -45,7 +46,11 @@ const VCHAR = ["\x21-\x7E"]; const OBS_TEXT = ["\x80-\xFF"]; - const REASON_PHRASE = [...HTTP_TAB_OR_SPACE, ...VCHAR, ...OBS_TEXT]; + const REASON_PHRASE = [ + ...new SafeArrayIterator(HTTP_TAB_OR_SPACE), + ...new SafeArrayIterator(VCHAR), + ...new SafeArrayIterator(OBS_TEXT), + ]; const REASON_PHRASE_MATCHER = regexMatcher(REASON_PHRASE); const REASON_PHRASE_RE = new RegExp(`^[${REASON_PHRASE_MATCHER}]*$`); @@ -90,9 +95,11 @@ * @returns {InnerResponse} */ function cloneInnerResponse(response) { - const urlList = [...response.urlList]; + const urlList = [...new SafeArrayIterator(response.urlList)]; const headerList = [ - ...ArrayPrototypeMap(response.headerList, (x) => [x[0], x[1]]), + ...new SafeArrayIterator( + ArrayPrototypeMap(response.headerList, (x) => [x[0], x[1]]), + ), ]; let body = null; if (response.body !== null) { diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 0c58bbf97..bbcbb44f0 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -38,6 +38,7 @@ Promise, PromisePrototypeThen, PromisePrototypeCatch, + SafeArrayIterator, String, StringPrototypeStartsWith, StringPrototypeToLowerCase, @@ -168,7 +169,7 @@ if (this.urlList.length == 0) return null; return this.urlList[this.urlList.length - 1]; }, - urlList: recursive ? [] : [...req.urlList], + urlList: recursive ? [] : [...new SafeArrayIterator(req.urlList)], }; } @@ -331,7 +332,7 @@ if (recursive) return response; if (response.urlList.length === 0) { - response.urlList = [...req.urlList]; + response.urlList = [...new SafeArrayIterator(req.urlList)]; } return response; |