fix(vt): keep OSC 8 hyperlinks when the URL contains semicolons - #950
Open
youdie006 wants to merge 1 commit into
Open
fix(vt): keep OSC 8 hyperlinks when the URL contains semicolons#950youdie006 wants to merge 1 commit into
youdie006 wants to merge 1 commit into
Conversation
An OSC 8 hyperlink was silently dropped when its URI contained a semicolon (e.g. https://example.com/f?a=1;b=2). handleHyperlink split the payload on every semicolon with bytes.Split, but the OSC 8 wire format is '8;params;uri' where only the first two semicolons are field separators; a URI with a semicolon produced four or more parts, so the len(parts) != 3 guard rejected the whole command. Split on only the first two semicolons with bytes.SplitN(data, ';', 3) so the URI keeps its own semicolons. The guard still rejects malformed payloads, and the reset sequence (8;;) and ordinary links are unaffected. Orthogonal to charmbracelet#868 (the params/uri field mapping); the added test is swap-agnostic. Fixes charmbracelet#937
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #937.
An OSC 8 hyperlink is silently dropped when its URI contains a semicolon (for example
https://example.com/f?a=1;b=2). The link text still renders, but the cells are never given the hyperlink, so it is not clickable.Root cause
handleHyperlinkinvt/osc.gosplit the payload on every semicolon:The OSC 8 wire format is
8 ; params ; uri, where only the first two semicolons are field separators -- any later semicolon belongs to the URI. A URI with a semicolon produces four or more parts, so thelen(parts) != 3guard rejects the whole command and the link is discarded.Fix
Split on only the first two semicolons with
bytes.SplitN(data, ';', 3), so the remainder (the URI) keeps its own semicolons. Thelen(parts) != 3guard still rejects malformed payloads with fewer than two semicolons, and the reset sequence (8;;) and ordinary links are unaffected.This is orthogonal to #868: that PR corrects which slot the params and URI are stored in (they are currently exchanged), while this PR fixes the parser dropping semicolon URIs entirely. The two changes compose -- the field mapping is left to #868. The added test asserts the URI survives in either
Link.URLorLink.Params, so it passes independently of #868's merge order.Test
TestHyperlinkURLWithSemicolondrivesEmulator.Writewith the issue's reproduction and asserts the semicolon URI reaches the cells' link.Link.URL/Link.Paramsboth empty -- FAIL.Full
vtsuite passes;gofmtandgo vetclean.AI-assisted: this change was prepared with the help of an AI coding assistant and reviewed by me.