util: fix OSC 8 hyperlink stripping in stripVTControlCharacters#64319
util: fix OSC 8 hyperlink stripping in stripVTControlCharacters#64319dushyant-hada-90 wants to merge 6 commits into
Conversation
| '[\\dA-PR-TZcf-nq-uy=><~]))', 'g', | ||
| '(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))' + | ||
| '|[\\u001B\\u009B][[\\]()#;?]*' + | ||
| '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?' + |
There was a problem hiding this comment.
not complete consistent with
(?:;\d{0,4})*
(?:[;:]\d{0,4})*
e3d3cb8 to
9da6ef2
Compare
|
Pushed updates addressing the feedback: Accepted the [;:] CSI parameter separator suggestion (@Archkon) and reworded the commit to follow commit message guidelines Verified the final regex against every added test case and confirmed it now matches upstream ansi-regex v6.2.0 exactly. |
The bundled ansi-regex OSC pattern used a restrictive URI character class that failed when URIs contained RFC 3986-valid characters such as parentheses. Match OSC sequences generically as ESC ] ... ST, aligned with ansi-regex v6.2.0. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Archkon <180910180+Archkon@users.noreply.github.com> Signed-off-by: dushyant <dushyanthada90@gmail.com>
Signed-off-by: dushyant <dushyanthada90@gmail.com>
9da6ef2 to
711b204
Compare
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: dushyant <dushyanthada90@gmail.com>
711b204 to
7a426b8
Compare
|
Hi @Archkon, @avivkeller |
Remove the extra non-capturing group around CSI parameters and the final byte so the bundled pattern matches ansi-regex at 72bc570 exactly. Refs: https://github.com/chalk/ansi-regex/blob/72bc570aaf25fca25541b49c6a8564f3ec63e835/index.js Signed-off-by: dushyant <dushyanthada90@gmail.com>
The previous comment claimed truncated OSC sequences were left unmatched rather than partially stripped. The CSI alternative can still consume a short prefix, which is why the expected remainder is 'ttps://...'. Update the comment to describe that behavior. Signed-off-by: dushyant <dushyanthada90@gmail.com>
Fixes: #64313
Summary
The bundled
ansi-regexOSC pattern used bystripVTControlCharacters()relied on a restrictive URI character class that failed when OSC 8 hyperlink URIs contained RFC 3986-valid characters such as(,),!,+,[and].This updates OSC handling to match sequences generically as:
aligned with
ansi-regexv6.2.0.Problem
stripVTControlCharacters()failed to correctly strip OSC 8 hyperlinks whose URI contained characters omitted from the previous regex character class:Example:
Actual
Expected
The OSC match terminated early at
(, leaving most of the escape sequence in the output.Changes
BEL,ESC \, or0x9C)ansi-regexv6.2.0Tests
Added regression coverage in:
for OSC 8 hyperlinks containing:
()!+[ ]across all supported OSC string terminators.
Notes