mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(terminal): fix OSC 8 parsing (#34424)
vterm does not send us the terminator in the string fragment. Our OSC 8
parser assumed that it was and therefore treated short strings as
invalid (as it assumed it was missing a terminator).
(cherry picked from commit b5aef05b8f
)
This commit is contained in:
committed by
github-actions[bot]
parent
5d0766ddce
commit
36c6f488e4
@ -283,31 +283,22 @@ static int parse_osc8(VTermStringFragment frag, int *attr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move past the semicolon
|
if (frag.str[i] != ';') {
|
||||||
i++;
|
|
||||||
|
|
||||||
if (i >= frag.len) {
|
|
||||||
// Invalid OSC sequence
|
// Invalid OSC sequence
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the terminator
|
// Move past the semicolon
|
||||||
const size_t start = i;
|
i++;
|
||||||
for (; i < frag.len; i++) {
|
|
||||||
if (frag.str[i] == '\a' || frag.str[i] == '\x1b') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t len = i - start;
|
if (i >= frag.len) {
|
||||||
if (len == 0) {
|
|
||||||
// Empty OSC 8, no URL
|
// Empty OSC 8, no URL
|
||||||
*attr = 0;
|
*attr = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *url = xmemdupz(&frag.str[start], len + 1);
|
char *url = xmemdupz(&frag.str[i], frag.len - i + 1);
|
||||||
url[len] = 0;
|
url[frag.len - i] = 0;
|
||||||
*attr = hl_add_url(0, url);
|
*attr = hl_add_url(0, url);
|
||||||
xfree(url);
|
xfree(url);
|
||||||
|
|
||||||
|
@ -398,12 +398,13 @@ describe(':terminal', function()
|
|||||||
[100] = { url = 'https://example.com' },
|
[100] = { url = 'https://example.com' },
|
||||||
}
|
}
|
||||||
local chan = api.nvim_open_term(0, {})
|
local chan = api.nvim_open_term(0, {})
|
||||||
api.nvim_chan_send(chan, '\027]8;;https://example.com\027\\Example\027]8;;\027\\')
|
api.nvim_chan_send(
|
||||||
screen:expect({
|
chan,
|
||||||
grid = [[
|
'This is an \027]8;;https://example.com\027\\example\027]8;;\027\\ of a link'
|
||||||
{100:^Example} |
|
)
|
||||||
|*6
|
screen:expect([[
|
||||||
]],
|
^This is an {100:example} of a link |
|
||||||
})
|
|*6
|
||||||
|
]])
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user