Permalink
Browse files

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.
  • Loading branch information...
1 parent 6a11f3e commit 9126dd2d903f3cf842f0c11a8349d794dde68e98 @TooTallNate TooTallNate committed Jul 4, 2012
Showing with 4 additions and 1 deletion.
  1. +1 −0 lib/repl.js
  2. +3 −1 test/simple/test-repl.js
View
@@ -883,6 +883,7 @@ function trimWhitespace(cmd) {
if (matches && matches.length === 2) {
return matches[1];
}
+ return '';
}
@@ -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 }' }
]);
}

1 comment on commit 9126dd2

@rlidwka
Member

@TooTallNate :

debugger relied on this:
https://github.com/joyent/node/blob/master/lib/_debugger.js#L955

it would be nice to fix it too :)

Please sign in to comment.