mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
csi: fix parsing of 256-color and 24-bit color SGRs
There may be more SGR sequences after the 256-color/24-bit sequence. Thus, check that we have *enough* parameters to parse the 256-color/24-bit SGR. It doesn't have to be *exactly* the required number of parameters though. Fixes issues with sequences like: \e[38;2;1;48;2;1m
This commit is contained in:
parent
ef944933e6
commit
0457c33418
1 changed files with 4 additions and 4 deletions
8
csi.c
8
csi.c
|
|
@ -139,14 +139,14 @@ csi_sgr(struct terminal *term)
|
|||
break;
|
||||
|
||||
case 38: {
|
||||
if (term->vt.params.idx - i - 1 == 2 &&
|
||||
if (term->vt.params.idx - i - 1 >= 2 &&
|
||||
term->vt.params.v[i + 1].value == 5)
|
||||
{
|
||||
size_t idx = term->vt.params.v[i + 2].value;
|
||||
term->vt.attrs.foreground = colors256[idx];
|
||||
term->vt.attrs.have_foreground = true;
|
||||
i += 2;
|
||||
} else if (term->vt.params.idx - i - 1 == 4 &&
|
||||
} else if (term->vt.params.idx - i - 1 >= 4 &&
|
||||
term->vt.params.v[i + 1].value == 2)
|
||||
{
|
||||
uint8_t r = term->vt.params.v[i + 2].value;
|
||||
|
|
@ -185,14 +185,14 @@ csi_sgr(struct terminal *term)
|
|||
break;
|
||||
|
||||
case 48: {
|
||||
if (term->vt.params.idx - i - 1 == 2 &&
|
||||
if (term->vt.params.idx - i - 1 >= 2 &&
|
||||
term->vt.params.v[i + 1].value == 5)
|
||||
{
|
||||
size_t idx = term->vt.params.v[i + 2].value;
|
||||
term->vt.attrs.background = colors256[idx];
|
||||
term->vt.attrs.have_background = true;
|
||||
i += 2;
|
||||
} else if (term->vt.params.idx - i - 1 == 4 &&
|
||||
} else if (term->vt.params.idx - i - 1 >= 4 &&
|
||||
term->vt.params.v[i + 1].value == 2)
|
||||
{
|
||||
uint8_t r = term->vt.params.v[i + 2].value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue