mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
Improve error reporting of incomplete SGR codes
This commit is contained in:
@@ -487,13 +487,23 @@ parse_sgr(Screen *screen, uint32_t *buf, unsigned int num, unsigned int *params,
|
|||||||
SEND_SGR;
|
SEND_SGR;
|
||||||
break;
|
break;
|
||||||
case COLOR1:
|
case COLOR1:
|
||||||
case COLOR3:
|
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
case MULTIPLE:
|
case MULTIPLE:
|
||||||
READ_PARAM;
|
if (i > num_start) { READ_PARAM; }
|
||||||
SEND_SGR;
|
if (num_params) { SEND_SGR; }
|
||||||
|
else { REPORT_ERROR("Incomplete SGR code"); }
|
||||||
break;
|
break;
|
||||||
default:
|
case COLOR:
|
||||||
|
REPORT_ERROR("Invalid SGR code containing incomplete semi-colon separated color sequence");
|
||||||
|
break;
|
||||||
|
case COLOR3:
|
||||||
|
if (i > num_start) READ_PARAM;
|
||||||
|
if (num_params != 5) {
|
||||||
|
REPORT_ERROR("Invalid SGR code containing incomplete semi-colon separated color sequence");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (num_params) { SEND_SGR; }
|
||||||
|
else { REPORT_ERROR("Incomplete SGR code"); }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#undef READ_PARAM
|
#undef READ_PARAM
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class TestParser(BaseTest):
|
|||||||
pb('\033[m', *sgr('0 '))
|
pb('\033[m', *sgr('0 '))
|
||||||
pb('\033[1;;2m', *sgr('1 0 2'))
|
pb('\033[1;;2m', *sgr('1 0 2'))
|
||||||
pb('\033[38;5;1m', ('select_graphic_rendition', '38 5 1 '))
|
pb('\033[38;5;1m', ('select_graphic_rendition', '38 5 1 '))
|
||||||
|
pb('\033[58;2;1;2;3m', ('select_graphic_rendition', '58 2 1 2 3 '))
|
||||||
pb('\033[38;2;1;2;3m', ('select_graphic_rendition', '38 2 1 2 3 '))
|
pb('\033[38;2;1;2;3m', ('select_graphic_rendition', '38 2 1 2 3 '))
|
||||||
pb('\033[1001:2:1:2:3m', ('select_graphic_rendition', '1001 2 1 2 3 '))
|
pb('\033[1001:2:1:2:3m', ('select_graphic_rendition', '1001 2 1 2 3 '))
|
||||||
pb('\033[38:2:1:2:3;48:5:9;58;5;7m', (
|
pb('\033[38:2:1:2:3;48:5:9;58;5;7m', (
|
||||||
|
|||||||
Reference in New Issue
Block a user