GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — readline: fix unicode line separators being ignored · nodejs/node@e2b94dc

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/readline
    • interface.js
  • test/parallel
    • test-readline-line-separators.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/readline/interface.js‎

Copy file name to clipboardExpand all lines: lib/internal/readline/interface.js
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,15 @@ const { StringDecoder } = require('string_decoder');
7878
const kHistorySize = 30;
7979
const kMaxUndoRedoStackSize = 2048;
8080
const kMincrlfDelay = 100;
81-
// \r\n, \n, or \r followed by something other than \n
82-
const lineEnding = /\r?\n|\r(?!\n)/g;
81+
/**
82+
* The end of a line is signaled by either one of the following:
83+
* - \r\n
84+
* - \n
85+
* - \r followed by something other than \n
86+
* - \u2028 (Unicode 'LINE SEPARATOR')
87+
* - \u2029 (Unicode 'PARAGRAPH SEPARATOR')
88+
*/
89+
const lineEnding = /\r?\n|\r(?!\n)|\u2028|\u2029/g;
8390

8491
const kLineObjectStream = Symbol('line object stream');
8592
const kQuestionCancel = Symbol('kQuestionCancel');
Collapse file

‎test/parallel/test-readline-line-separators.js‎

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('node:assert');
4+
const readline = require('node:readline');
5+
const { Readable } = require('node:stream');
6+
7+
const str = '012\n345\r67\r\n89\u{2028}ABC\u{2029}DEF';
8+
9+
const rli = new readline.Interface({
10+
input: Readable.from(str),
11+
});
12+
13+
const linesRead = [];
14+
rli.on('line', (line) => linesRead.push(line));
15+
16+
rli.on('close', common.mustCall(() => {
17+
assert.deepStrictEqual(linesRead, ['012', '345', '67', '89', 'ABC', 'DEF']);
18+
}));

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.