termptyesc: 98/108 are not valid color codes + test

This commit is contained in:
Boris Faure 2018-12-16 19:08:59 +01:00
parent add8b71778
commit eab5ffb956
3 changed files with 11 additions and 57 deletions

View File

@ -1078,35 +1078,6 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
ty->termstate.att.fg = (arg - 90) + COL_BLACK;
ty->termstate.att.fgintense = 1;
break;
case 98: // xterm 256 fg color ???
// now check if next arg is 5
/* TODO: shall be like 38 ? */
/* TODO: -CSI_ARG_NO_VALUE */
arg = _csi_arg_get(ty, &b);
if (arg != 5)
{
ERR("Failed xterm 256 color fg esc 5 (got %d)", arg);
ty->decoding_error = EINA_TRUE;
}
else
{
// then get next arg - should be color index 0-255
arg = _csi_arg_get(ty, &b);
if (arg <= -CSI_ARG_ERROR || arg > 255)
{
ERR("Invalid fg color %d", arg);
ty->decoding_error = EINA_TRUE;
}
else
{
if (arg == -CSI_ARG_NO_VALUE)
arg = 0;
ty->termstate.att.fg256 = 1;
ty->termstate.att.fg = arg;
}
}
ty->termstate.att.fgintense = 1;
break;
case 99: // default fg color
ty->termstate.att.fg256 = 0;
ty->termstate.att.fg = COL_DEF;
@ -1124,34 +1095,6 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
ty->termstate.att.bg = (arg - 100) + COL_BLACK;
ty->termstate.att.bgintense = 1;
break;
case 108: // xterm 256 bg color ???
// now check if next arg is 5
/* TODO: -CSI_ARG_NO_VALUE */
arg = _csi_arg_get(ty, &b);
if (arg != 5)
{
ERR("Failed xterm 256 color bg esc 5 (got %d)", arg);
ty->decoding_error = EINA_TRUE;
}
else
{
// then get next arg - should be color index 0-255
arg = _csi_arg_get(ty, &b);
if (arg <= -CSI_ARG_ERROR || arg > 255)
{
ERR("Invalid bg color %d", arg);
ty->decoding_error = EINA_TRUE;
}
else
{
if (arg == -CSI_ARG_NO_VALUE)
arg = 0;
ty->termstate.att.bg256 = 1;
ty->termstate.att.bg = arg;
}
}
ty->termstate.att.bgintense = 1;
break;
case 109: // default bg color
ty->termstate.att.bg256 = 0;
ty->termstate.att.bg = COL_DEF;

10
tests/sgr-long.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# long sequence
printf '\033[0;1;2;3;4;5;9;20;38;5;58;48;5;34;52;53mo'
# long sequence with 98/108 which are not allowed, were producing the same
printf '\033[0;1;2;3;4;5;9;20;98;5;58;108;5;34;52;53mo'
printf '\n'
# both shall provide the same output
printf '\033[0;5;58;5;34mo\033[0;98;5;58;108;5;34mo'

View File

@ -28,3 +28,4 @@ dsr-udk.sh f3a20968a2f25bfd36875dbc5f64ab16
colors.sh 532494a2e56c102ee10ab1a9b8f176d7
sgr-leading-trailing-semicolon.sh d7701f1193bde63412a9b969f17e10ec
sgr-truecolors.sh 9db4becc728bb9f1730f3573dc7fc668
sgr-long.sh ec0425b1daabaa59096c10939e79b105