Skip to content

Commit

Permalink
Revert "fixup! short circuit with toWeb"
Browse files Browse the repository at this point in the history
This reverts commit 06d670f.
  • Loading branch information
debadree25 committed Jul 13, 2023
1 parent bf08711 commit bfefd98
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 107 deletions.
14 changes: 2 additions & 12 deletions lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const {
SymbolAsyncDispose,
SymbolAsyncIterator,
Symbol,
SymbolFor,
} = primordials;

module.exports = Readable;
Expand Down Expand Up @@ -75,12 +74,6 @@ const { validateObject } = require('internal/validators');

const kPaused = Symbol('kPaused');

// This symbol is used to allow interop with ReadableStream
// to allow checking for prototype pollution in the
// async iterator to allow for using the toWeb functionality
// in ReadableStream.from() implementation.
const originalAsyncIteratorPrototype = SymbolFor('nodejs.stream.originalAsyncIteratorPrototype');

const { StringDecoder } = require('string_decoder');
const from = require('internal/streams/from');

Expand Down Expand Up @@ -1101,12 +1094,9 @@ Readable.prototype.wrap = function(stream) {
return this;
};

function asyncIteratorPrototype() {
Readable.prototype[SymbolAsyncIterator] = function() {
return streamToAsyncIterator(this);
}

Readable.prototype[SymbolAsyncIterator] = asyncIteratorPrototype;
Readable.prototype[originalAsyncIteratorPrototype] = asyncIteratorPrototype;
};

Readable.prototype.iterator = function(options) {
if (options !== undefined) {
Expand Down
29 changes: 6 additions & 23 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const {
Symbol,
SymbolAsyncIterator,
SymbolToStringTag,
SymbolFor,
Uint8Array,
} = primordials;

Expand Down Expand Up @@ -83,7 +82,6 @@ const {
kIsReadable,
kIsClosedPromise,
kControllerErrorFunction,
isReadableNodeStream,
} = require('internal/streams/utils');

const {
Expand Down Expand Up @@ -141,18 +139,9 @@ const kChunk = Symbol('kChunk');
const kError = Symbol('kError');
const kPull = Symbol('kPull');
const kRelease = Symbol('kRelease');
const kReadableOriginalAsyncIteratorPrototype = SymbolFor('nodejs.stream.originalAsyncIteratorPrototype');

let releasedError;
let releasingError;
let readableStreamAdapters;

function lazyReadableStreamAdapters() {
if (!readableStreamAdapters) {
readableStreamAdapters = require('internal/webstreams/adapters');
}
return readableStreamAdapters;
}

const userModuleRegExp = /^ {4}at (?:[^/\\(]+ \()(?!node:(.+):\d+:\d+\)$).*/gm;

Expand Down Expand Up @@ -1266,17 +1255,6 @@ const isReadableStreamBYOBReader =
// ---- ReadableStream Implementation

function readableStreamFromIterable(iterable) {
const strategy = {
size() {
return 1;
},
highWaterMark: 0,
};
if (isReadableNodeStream(iterable) &&
iterable[kReadableOriginalAsyncIteratorPrototype] === iterable[SymbolAsyncIterator]) {
return lazyReadableStreamAdapters().newReadableStreamFromStreamReadable(iterable, strategy);
}

let stream;
const iteratorRecord = getIterator(iterable, 'async');

Expand Down Expand Up @@ -1319,7 +1297,12 @@ function readableStreamFromIterable(iterable) {
start: startAlgorithm,
pull: pullAlgorithm,
cancel: cancelAlgorithm,
}, strategy);
}, {
size() {
return 1;
},
highWaterMark: 0,
});

return stream;
}
Expand Down
72 changes: 0 additions & 72 deletions test/parallel/test-readablestream-from-prototype-pollution.js

This file was deleted.

0 comments on commit bfefd98

Please sign in to comment.