diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-04 07:57:02 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-04 07:57:02 +0000 |
| commit | 0457c334181a62c192c6f1ae03eea0d75f424e24 (patch) | |
| tree | 3cb4834e3b7c5f559e78db47d301986de070589f | |
| parent | flash mitigation: add a small delay before rendering after receiving client data (diff) | |
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
| -rw-r--r-- | csi.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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; |
