node/lib/internal/readline
Theodor Steiner 333aff0dc6
repl: fix .load infinite loop caused by shared use of lineEnding RegExp
Since the lineEnding Regular Expression is declared on the module scope,
recursive invocations of its `[kTtyWrite]` method share one instance of
this Regular Expression.
Since the state of a RegExp is managed by instance,
alternately calling RegExpPrototypeExec with the same RegExp on
different strings can lead to the state changing unexpectedly.
This is the root cause of this infinite loop bug when calling .load on
javascript files of certain shapes.

PR-URL: https://github.com/nodejs/node/pull/46742
Fixes: https://github.com/nodejs/node/issues/46731
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-03-01 14:18:05 +00:00
..
callbacks.js lib: replace validator and error 2022-02-05 08:36:48 -08:00
emitKeypressEvents.js readline: refactor Interface to ES2015 class 2021-09-16 23:16:34 +02:00
interface.js repl: fix .load infinite loop caused by shared use of lineEnding RegExp 2023-03-01 14:18:05 +00:00
promises.js readline: add autoCommit option 2021-09-16 23:16:46 +02:00
utils.js lib: enforce use of trailing commas in more files 2023-02-16 18:47:24 +01:00