chalk/strip-ansi

strip-ansi improperly parses OSC8 stops #51

llimllib posted onGitHub

regarding OSC control sequences, wiki states:

Most Operating System Command sequences were defined by Xterm, but many are also supported by other terminal emulators. For historical reasons, Xterm can end the command with BEL (0x07) as well as the standard ST (0x9C or 0x1B 0x5C).[13] For example, Xterm allows the window title to be set by ESC ]0;this is the window title BEL.

(emphasis mine)

strip-ansi correctly parses the BEL character as a stop:

$ node
Welcome to Node.js v22.4.0.
Type ".help" for more information.
> stripAnsi = (await import('strip-ansi')).default
[Function: stripAnsi]
> stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
'Click'

however, it does not correctly parse either 0x9c or 0x1B 0x5C as an ST:

> stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u009c');
'Click;;\x9C'
> stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u001b\u005c');
'Click;;\x1B\\'

As far as I know, there is no actual spec to point to, just behavior to observe from different terminal emulators. In the OSC8 spec such as it is, 0x1b5c is used at the ST character so I feel that it should be supported.


ah ha, thanks to sindorhesus this appears to be due to https://github.com/chalk/ansi-regex/issues/56 ; I'll close this issue out for that one

posted by llimllib 7 months ago

Fund this Issue

$0.00
Funded

Pull requests