Use indexOf(';') approach

This commit is contained in:
Daniel Imms
2024-04-21 08:30:45 -07:00
parent 487278ac79
commit 0e77f839ff
+10 -6
View File
@@ -2972,14 +2972,18 @@ export class InputHandler extends Disposable implements IInputHandler {
* feedback. Use `OSC 8 ; ; BEL` to finish the current hyperlink.
*/
public setHyperlink(data: string): boolean {
const args = data.match(/^([^;]*);(.*)$/)?.slice(1) ?? [];
if (args.length < 2) {
return false;
// Arg parsing is special cases to support unencoded semi-colons in the URIs (#4944)
const idx = data.indexOf(';');
if (idx === -1) {
// malformed sequence, just return as handled
return true;
}
if (args[1]) {
return this._createHyperlink(args[0], args[1]);
const id = data.slice(0, idx).trim();
const uri = data.slice(idx + 1);
if (uri) {
return this._createHyperlink(id, uri);
}
if (args[0].trim()) {
if (id.trim()) {
return false;
}
return this._finishHyperlink();