From 9126dd2d903f3cf842f0c11a8349d794dde68e98 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 4 Jul 2012 11:51:24 -0700 Subject: [PATCH] repl: fix passing an empty line inserting "undefined" into the buffer There was a possiblity of insering the string "undefined" into the repl's command buffer, which would cause interesting results while evaluating. --- lib/repl.js | 1 + test/simple/test-repl.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/repl.js b/lib/repl.js index 29c6d0eb491..3e5f33a4718 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -883,6 +883,7 @@ function trimWhitespace(cmd) { if (matches && matches.length === 2) { return matches[1]; } + return ''; } diff --git a/test/simple/test-repl.js b/test/simple/test-repl.js index dccff9cf5db..6cf2aaaac30 100644 --- a/test/simple/test-repl.js +++ b/test/simple/test-repl.js @@ -152,7 +152,9 @@ function error_test() { { client: client_unix, send: 'npm install foobar', expect: expect_npm }, { client: client_unix, send: '(function () {\n\nreturn 1;\n})()', - expect: '1' } + expect: '1' }, + { client: client_unix, send: '{\n\na: 1\n}', + expect: '{ a: 1 }' } ]); }