Skip to content

Commit

Permalink
stream: dont access Object.prototype.type during TransformStream init
Browse files Browse the repository at this point in the history
Fixes: #46355
PR-URL: #46389
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
debadree25 authored and MylesBorins committed Feb 18, 2023
1 parent 905a675 commit b844a09
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/internal/webstreams/transformstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ function initializeTransformStream(
readableSizeAlgorithm) {

const writable = new WritableStream({
__proto__: null,
start() { return startPromise.promise; },
write(chunk) {
return transformStreamDefaultSinkWriteAlgorithm(stream, chunk);
Expand All @@ -374,6 +375,7 @@ function initializeTransformStream(
});

const readable = new ReadableStream({
__proto__: null,
start() { return startPromise.promise; },
pull() {
return transformStreamDefaultSourcePullAlgorithm(stream);
Expand Down
19 changes: 19 additions & 0 deletions test/parallel/test-whatwg-transformstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,22 @@ class Source {
inspect(controller, { depth: 0 }),
/TransformStreamDefaultController \[/);
}

{
Object.defineProperty(Object.prototype, 'type', {
get: common.mustNotCall('get %Object.prototype%.type'),
set: common.mustNotCall('set %Object.prototype%.type'),
configurable: true,
});

new TransformStream({
transform(chunk, controller) {
controller.enqueue(chunk);
},
flush(controller) {
controller.terminate();
}
});

delete Object.prototype.type;
}

0 comments on commit b844a09

Please sign in to comment.