Skip to content

osc: keep verbatim OSC 7/8/9;9 payloads whole - #1983

Open
raphamorim wants to merge 1 commit into
mainfrom
osc8-verbatim-uri
Open

raphamorim wants to merge 1 commit into
mainfrom
osc8-verbatim-uri

Conversation

@raphamorim

Copy link
Copy Markdown
Owner

OSC 7, OSC 8 and OSC 9;9 carry verbatim payloads, but the OSC parser split them on every ; and kept at most 16 params. OSC 8 then used only the third param as the URI, so https://x.dev/a;b opened as https://x.dev/a, and OSC 7 / 9;9 rejoined the split params in the handler, which still lost anything past the 16th ;.

The parser now stops splitting once it reaches the verbatim part of these sequences, keeping the ; as data: after 7;, after 8;<params>;, and after 9;9;. Other OSCs (including 9;4 progress) split as before. The check runs only on a ; while the param count is 1 or 2, so the hot path is unchanged. join_params is gone.

OSC 8 handling:

  • the URI is everything after the second ;, however many ; it contains
  • a URI with invalid UTF-8 is decoded lossily and starts a new link, instead of the old text staying attached to the previous link
  • an empty URI always closes the link, also when an id is given; an empty id= counts as no id
  • hint labels, hover and click open the URI exactly as the program sent it; post-processing (trailing punctuation, unmatched brackets) now only applies to regex matches

Cleanup: the regex hint path uses trim_match_tail instead of its duplicate post_process_hyperlink_uri, and the duplicate copy in screen/mod.rs is removed. The old tests moved over, plus a case for a leading unmatched delimiter.

Tests: parser tests for OSC 8, 7 and 9;9 payloads with more than 16 ; and for 9;4 still splitting; terminal tests for ; in an OSC 8 URI, invalid UTF-8 and 8;id=foo; closing.

Docs (post-processing scope, OSC 8 URI rule, changelog) are on the osc8-verbatim-uri branch of rioterm.com.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant