termptyesc: handle invalid values for OSC + test
- missing value is as if 0 - overflow - hex - negative value
This commit is contained in:
parent
bde94adf21
commit
2e75539fb9
|
@ -3387,22 +3387,44 @@ unhandled:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_osc_arg_get(Eina_Unicode **ptr)
|
_osc_arg_get(Termpty *ty, Eina_Unicode **ptr)
|
||||||
{
|
{
|
||||||
Eina_Unicode *b = *ptr;
|
Eina_Unicode *b = *ptr;
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
|
||||||
|
if ((b == NULL) || (*b == '\0'))
|
||||||
|
{
|
||||||
|
*ptr = NULL;
|
||||||
|
sum = -ESC_ARG_NO_VALUE;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
while (*b >= '0' && *b <= '9')
|
while (*b >= '0' && *b <= '9')
|
||||||
{
|
{
|
||||||
sum *= 10;
|
sum *= 10;
|
||||||
sum += *b - '0';
|
sum += *b - '0';
|
||||||
b++;
|
b++;
|
||||||
|
if (sum >= 65536)
|
||||||
|
{
|
||||||
|
sum = -ESC_ARG_ERROR;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (*b != ';')
|
if (*b != ';')
|
||||||
sum = -1;
|
{
|
||||||
|
sum = -ESC_ARG_ERROR;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
b++;
|
b++;
|
||||||
*ptr = b;
|
*ptr = b;
|
||||||
|
|
||||||
|
return sum;
|
||||||
|
|
||||||
|
error:
|
||||||
|
ERR("Invalid OSC argument");
|
||||||
|
ty->decoding_error = EINA_TRUE;
|
||||||
|
*ptr = NULL;
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3728,11 +3750,13 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
arg = _osc_arg_get(&p);
|
arg = _osc_arg_get(ty, &p);
|
||||||
switch (arg)
|
switch (arg)
|
||||||
{
|
{
|
||||||
case -1:
|
case -ESC_ARG_ERROR:
|
||||||
goto err;
|
goto err;
|
||||||
|
case -ESC_ARG_NO_VALUE:
|
||||||
|
EINA_FALLTHROUGH;
|
||||||
case 0:
|
case 0:
|
||||||
// title + icon name
|
// title + icon name
|
||||||
if (!*p)
|
if (!*p)
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# fill space with E
|
||||||
|
printf '\033#8'
|
||||||
|
#set color
|
||||||
|
printf '\033[46;31;3m'
|
||||||
|
|
||||||
|
# set title + icon
|
||||||
|
printf '\033]0;foobar\007'
|
||||||
|
|
||||||
|
# set again title + icon with no command
|
||||||
|
printf '\033];no command\007'
|
||||||
|
|
||||||
|
# set again title + icon with id as double
|
||||||
|
printf '\033]00;double\007'
|
||||||
|
|
||||||
|
# set again title + icon with id as hex
|
||||||
|
printf '\033]0x0;hex\007'
|
||||||
|
|
||||||
|
# set again title + icon with id as negative zero
|
||||||
|
printf '\033]-0;negative zero\007'
|
||||||
|
|
||||||
|
# set again title + icon with id as negative value
|
||||||
|
printf '\033]-2;negative value\007'
|
||||||
|
|
||||||
|
# set again title + icon with space
|
||||||
|
printf '\033] 0;with spaces\007'
|
||||||
|
|
||||||
|
# set again title + icon with space
|
||||||
|
printf '\033]0 ;with spaces v2\007'
|
||||||
|
|
||||||
|
# set again title + icon with overflow
|
||||||
|
printf '\033]99999999999999999999999999999999999999999999999999;overflow\007'
|
|
@ -122,3 +122,4 @@ osc-11-query.sh b762d503e40641ff896dac46391ad7a8
|
||||||
link_detection.sh bbe87a849586e8b922f26ad5d88146dc
|
link_detection.sh bbe87a849586e8b922f26ad5d88146dc
|
||||||
selection_with_tabs.sh 23557497a8f28ca246048bb2443b3dab
|
selection_with_tabs.sh 23557497a8f28ca246048bb2443b3dab
|
||||||
selection_empty_lines.sh 7a90d9bfde9e9fb7f067f6c08eac57ff
|
selection_empty_lines.sh 7a90d9bfde9e9fb7f067f6c08eac57ff
|
||||||
|
osc-invalid.sh 0acecbe16bb3b257745787c40affdb90
|
||||||
|
|
Loading…
Reference in New Issue