From 0d6dbc08bec50aa1548703bf53dc632e0aeefbd6 Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Fri, 14 Oct 2022 11:38:17 +0200 Subject: [PATCH] fix(ext/fetch): throw TypeError on non-Uint8Array chunk (#16262) --- ext/web/06_streams.js | 6 ++++++ tools/wpt/expectation.json | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 933d7b09ca..361e5e0556 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -813,6 +813,12 @@ const { value: chunk, done } = await reader.read(); if (done) break; + if (!ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, chunk)) { + throw new TypeError( + "Can't convert value to Uint8Array while consuming the stream", + ); + } + ArrayPrototypePush(chunks, chunk); totalLength += chunk.byteLength; } diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json index e9dfa03d0a..558ada79aa 100644 --- a/tools/wpt/expectation.json +++ b/tools/wpt/expectation.json @@ -3003,6 +3003,8 @@ "response-static-error.any.worker.html": true, "response-static-redirect.any.html": true, "response-static-redirect.any.worker.html": true, + "response-stream-bad-chunk.any.html": true, + "response-stream-bad-chunk.any.worker.html": true, "response-stream-disturbed-1.any.html": true, "response-stream-disturbed-1.any.worker.html": true, "response-stream-disturbed-2.any.html": true,