mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
e7391967c2
The REPL implementation would strip away the first and last character of a formatted error message if it ended with `]` (but with the obviously missing check for a starting `]`), leading to things like `Uncaught rror: foo[a` being printed for input like `Error: foo[a]`. Refs: https://github.com/nodejs/node/pull/22436 PR-URL: https://github.com/nodejs/node/pull/38209 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
24 lines
484 B
JavaScript
24 lines
484 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const { PassThrough } = require('stream');
|
|
const assert = require('assert');
|
|
const repl = require('repl');
|
|
|
|
{
|
|
const input = new PassThrough();
|
|
const output = new PassThrough();
|
|
|
|
const r = repl.start({
|
|
prompt: '',
|
|
input,
|
|
output,
|
|
writer: String,
|
|
terminal: false,
|
|
useColors: false
|
|
});
|
|
|
|
r.write('throw new Error("foo[a]")\n');
|
|
r.close();
|
|
assert.strictEqual(output.read().toString(), 'Uncaught Error: foo[a]\n');
|
|
}
|