readline: fix unicode line separators being ignored

PR-URL: https://github.com/nodejs/node/pull/57591
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Dario Piotrowicz 2025-03-22 18:47:55 +00:00 committed by James M Snell
parent dfaded80e1
commit a42bca5fa7
2 changed files with 27 additions and 2 deletions

View file

@ -78,8 +78,15 @@ const { StringDecoder } = require('string_decoder');
const kHistorySize = 30;
const kMaxUndoRedoStackSize = 2048;
const kMincrlfDelay = 100;
// \r\n, \n, or \r followed by something other than \n
const lineEnding = /\r?\n|\r(?!\n)/g;
/**
* The end of a line is signaled by either one of the following:
* - \r\n
* - \n
* - \r followed by something other than \n
* - \u2028 (Unicode 'LINE SEPARATOR')
* - \u2029 (Unicode 'PARAGRAPH SEPARATOR')
*/
const lineEnding = /\r?\n|\r(?!\n)|\u2028|\u2029/g;
const kLineObjectStream = Symbol('line object stream');
const kQuestionCancel = Symbol('kQuestionCancel');