Skip to content

util.stripVTControlCharacters does not strip hyperlinks#53697

@isaacs

Description

@isaacs

Version

22.4.0

Platform

Darwin moxy.lan 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:17:33 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6031 arm64 

Subsystem

util

What steps will reproduce the bug?

console.log(util.stripVTControlCharacters('\x1b]8;http://example.com\x1b\\This is a link\x1b]8;\x1b\\ hello')) 

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Should output:

This is a link hello 

(With "This is a link" not hyperlinked.)

What do you see instead?

ttp://example.comThis is a link; hello 

Additional information

OCS codes are a bit tricky to capture and strip, but this is what I'm using in ansi-to-pre:

/\u001B\]8;(.*?)(?:\u001B\\|\u0007)(.*?)\u001B]8;(?\u001B\\|\u0007)/ 

Adding str.replaceAll(/\u001b\]8;(.*?)(?:\u001b\\|\u0007)(.*?)\u001b]8;(?:\u001b\\|\u0007)/g, '$2') should do the right thing, but not sure if there's some better way to do it in context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions