Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b09953d

Browse filesBrowse files
daeyeonaduh95
authored andcommitted
stream: reject duplicate nested transferables
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com> PR-URL: #62831 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com> Reviewed-By: Mattias Buelens <mattias@buelens.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
1 parent 981ce96 commit b09953d
Copy full SHA for b09953d

3 files changed

+26-10Lines changed: 26 additions & 10 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_messaging.cc‎

Copy file name to clipboardExpand all lines: src/node_messaging.cc
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,15 @@ class SerializerDelegate : public ValueSerializer::Delegate {
415415
if (!host_objects_[i]->NestedTransferables().To(&nested_transferables))
416416
return Nothing<bool>();
417417
for (auto& nested_transferable : nested_transferables) {
418-
if (std::ranges::find(host_objects_, nested_transferable) ==
418+
if (std::ranges::find(host_objects_, nested_transferable) !=
419419
host_objects_.end()) {
420-
AddHostObject(nested_transferable);
420+
ThrowDataCloneException(
421+
context_,
422+
FIXED_ONE_BYTE_STRING(env_->isolate(),
423+
"The transfer list is invalid."));
424+
return Nothing<bool>();
421425
}
426+
AddHostObject(nested_transferable);
422427
}
423428
}
424429
return Just(true);
Collapse file
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('node:assert');
5+
6+
const combinations = [
7+
((t) => [t, t.readable])(new TransformStream()),
8+
((t) => [t.readable, t])(new TransformStream()),
9+
((t) => [t, t.writable])(new TransformStream()),
10+
((t) => [t.writable, t])(new TransformStream()),
11+
];
12+
13+
for (const combination of combinations) {
14+
assert.throws(() => structuredClone(combination, { transfer: combination }), {
15+
constructor: DOMException,
16+
name: 'DataCloneError',
17+
code: 25,
18+
});
19+
}
Collapse file

‎test/wpt/status/streams.json‎

Copy file name to clipboardExpand all lines: test/wpt/status/streams.json
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@
4141
"transferable/transfer-with-messageport.window.js": {
4242
"skip": "Browser-specific test"
4343
},
44-
"transferable/transform-stream-members.any.js": {
45-
"fail": {
46-
"expected": [
47-
"Transferring [object TransformStream],[object ReadableStream] should fail",
48-
"Transferring [object TransformStream],[object WritableStream] should fail"
49-
]
50-
}
51-
},
5244
"transform-streams/invalid-realm.tentative.window.js": {
5345
"skip": "Browser-specific test"
5446
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.