repl: do not consider ...
as a REPL command
This fix makes ... in REPL to be considered as a javascript construct rather than a REPL keyword. Fixes: https://github.com/nodejs/node/issues/14426 PR-URL: https://github.com/nodejs/node/pull/14467 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
0fab3b04ba
commit
46d3ff2af9
@ -419,7 +419,8 @@ function REPLServer(prompt,
|
|||||||
// Check to see if a REPL keyword was used. If it returns true,
|
// Check to see if a REPL keyword was used. If it returns true,
|
||||||
// display next prompt and return.
|
// display next prompt and return.
|
||||||
if (trimmedCmd) {
|
if (trimmedCmd) {
|
||||||
if (trimmedCmd.charAt(0) === '.' && isNaN(parseFloat(trimmedCmd))) {
|
if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' &&
|
||||||
|
isNaN(parseFloat(trimmedCmd))) {
|
||||||
const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/);
|
const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/);
|
||||||
const keyword = matches && matches[1];
|
const keyword = matches && matches[1];
|
||||||
const rest = matches && matches[2];
|
const rest = matches && matches[2];
|
||||||
|
@ -414,7 +414,13 @@ function error_test() {
|
|||||||
expect: `${prompt_multiline}'foo \\n'\n${prompt_unix}` },
|
expect: `${prompt_multiline}'foo \\n'\n${prompt_unix}` },
|
||||||
// Whitespace is not evaluated.
|
// Whitespace is not evaluated.
|
||||||
{ client: client_unix, send: ' \t \n',
|
{ client: client_unix, send: ' \t \n',
|
||||||
expect: prompt_unix }
|
expect: prompt_unix },
|
||||||
|
// Do not parse `...[]` as a REPL keyword
|
||||||
|
{ client: client_unix, send: '...[]\n',
|
||||||
|
expect: `${prompt_multiline}` },
|
||||||
|
// bring back the repl to prompt
|
||||||
|
{ client: client_unix, send: '.break',
|
||||||
|
expect: `${prompt_unix}` }
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user