Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: backslash bug fix #2968

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,9 @@ function REPLServer(prompt,

for (var i = 0; i < line.length; i += 1) {
if (previous === '\\') {
// if it is a valid escaping, then skip processing
previous = current;
// if it is a valid escaping, then skip processing and the previous
// character doesn't matter anymore.
previous = null;
continue;
}

Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ function error_test() {
'RegExp.$6\nRegExp.$7\nRegExp.$8\nRegExp.$9\n',
expect: ['\'1\'\n', '\'2\'\n', '\'3\'\n', '\'4\'\n', '\'5\'\n', '\'6\'\n',
'\'7\'\n', '\'8\'\n', '\'9\'\n'].join(`${prompt_unix}`) },
// regression tests for https://github.com/nodejs/node/issues/2749
{ client: client_unix, send: 'function x() {\nreturn \'\\n\';\n }',
expect: prompt_multiline + prompt_multiline +
'undefined\n' + prompt_unix },
{ client: client_unix, send: 'function x() {\nreturn \'\\\\\';\n }',
expect: prompt_multiline + prompt_multiline +
'undefined\n' + prompt_unix },
]);
}

Expand Down