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 d6124d8

Browse filesBrowse files
MesteeryBethGriggs
authored andcommitted
repl: fix top level await with surrogate characters
Fixes: #39929 PR-URL: #39931 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
1 parent edcfffe commit d6124d8
Copy full SHA for d6124d8

File tree

Expand file treeCollapse file tree

2 files changed

+19
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/repl/await.js‎

Copy file name to clipboardExpand all lines: lib/internal/repl/await.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const {
4-
ArrayFrom,
54
ArrayPrototypeForEach,
65
ArrayPrototypeIncludes,
76
ArrayPrototypeJoin,
@@ -155,7 +154,7 @@ for (const nodeType of ObjectKeys(walk.base)) {
155154
function processTopLevelAwait(src) {
156155
const wrapPrefix = '(async () => { ';
157156
const wrapped = `${wrapPrefix}${src} })()`;
158-
const wrappedArray = ArrayFrom(wrapped);
157+
const wrappedArray = StringPrototypeSplit(wrapped, '');
159158
let root;
160159
try {
161160
root = parser.parse(wrapped, { ecmaVersion: 'latest' });
Collapse file

‎test/parallel/test-repl-preprocess-top-level-await.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-preprocess-top-level-await.js
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,31 @@ const { processTopLevelAwait } = require('internal/repl/await');
99
// This test was created based on
1010
// https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/http/tests/inspector-unit/preprocess-top-level-awaits.js?rcl=358caaba5e763e71c4abb9ada2d9cd8b1188cac9
1111

12+
const surrogate = (
13+
'"\u{1F601}\u{1f468}\u200d\u{1f469}\u200d\u{1f467}\u200d\u{1f466}"'
14+
);
15+
1216
const testCases = [
1317
[ '0',
1418
null ],
1519
[ 'await 0',
1620
'(async () => { return (await 0) })()' ],
21+
[ `await ${surrogate}`,
22+
`(async () => { return (await ${surrogate}) })()` ],
1723
[ 'await 0;',
1824
'(async () => { return (await 0); })()' ],
25+
[ `await ${surrogate};`,
26+
`(async () => { return (await ${surrogate}); })()` ],
27+
[ `await ${surrogate};`,
28+
`(async () => { return (await ${surrogate}); })()` ],
1929
[ '(await 0)',
2030
'(async () => { return ((await 0)) })()' ],
31+
[ `(await ${surrogate})`,
32+
`(async () => { return ((await ${surrogate})) })()` ],
2133
[ '(await 0);',
2234
'(async () => { return ((await 0)); })()' ],
35+
[ `(await ${surrogate});`,
36+
`(async () => { return ((await ${surrogate})); })()` ],
2337
[ 'async function foo() { await 0; }',
2438
null ],
2539
[ 'async () => await 0',
@@ -28,8 +42,12 @@ const testCases = [
2842
null ],
2943
[ 'await 0; return 0;',
3044
null ],
45+
[ `await ${surrogate}; await ${surrogate};`,
46+
`(async () => { await ${surrogate}; return (await ${surrogate}); })()` ],
3147
[ 'var a = await 1',
3248
'var a; (async () => { void (a = await 1) })()' ],
49+
[ `var a = await ${surrogate}`,
50+
`var a; (async () => { void (a = await ${surrogate}) })()` ],
3351
[ 'let a = await 1',
3452
'let a; (async () => { void (a = await 1) })()' ],
3553
[ 'const a = await 1',

0 commit comments

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