termptyesc: act like xterm, do not report title/icon-name

This commit is contained in:
Boris Faure 2018-12-09 16:06:42 +01:00
parent e4d7cb93f2
commit 479d96e5dc
5 changed files with 89 additions and 53 deletions

View File

@ -2018,84 +2018,60 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
case -1:
goto err;
case 0:
// XXX: title + name - callback
// title + icon name
if (!*p)
goto err;
if (*p == '?')
s = eina_unicode_unicode_to_utf8(p, &len);
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
if (s)
{
/* returns empty string. See CVE-2003-0063 */
TERMPTY_WRITE_STR("\033]0;Terminology\007");
ty->prop.title = eina_stringshare_add(s);
ty->prop.icon = eina_stringshare_add(s);
free(s);
}
else
{
s = eina_unicode_unicode_to_utf8(p, &len);
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
if (s)
{
ty->prop.title = eina_stringshare_add(s);
ty->prop.icon = eina_stringshare_add(s);
free(s);
}
else
{
ty->prop.title = NULL;
ty->prop.icon = NULL;
}
if (ty->cb.set_title.func)
ty->cb.set_title.func(ty->cb.set_title.data);
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
ty->prop.title = NULL;
ty->prop.icon = NULL;
}
if (ty->cb.set_title.func)
ty->cb.set_title.func(ty->cb.set_title.data);
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
break;
case 1:
// XXX: icon name - callback
// icon name
if (!*p)
goto err;
if (*p == '?')
s = eina_unicode_unicode_to_utf8(p, &len);
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
if (s)
{
/* returns empty string. See CVE-2003-0063 */
TERMPTY_WRITE_STR("\033]1;Terminology\007");
ty->prop.icon = eina_stringshare_add(s);
free(s);
}
else
{
s = eina_unicode_unicode_to_utf8(p, &len);
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
if (s)
{
ty->prop.icon = eina_stringshare_add(s);
free(s);
}
else
{
ty->prop.icon = NULL;
}
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
ty->prop.icon = NULL;
}
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
break;
case 2:
// XXX: title - callback
// Title
if (!*p)
goto err;
if (*p == '?')
s = eina_unicode_unicode_to_utf8(p, &len);
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
if (s)
{
/* returns empty string. See CVE-2003-0063 */
TERMPTY_WRITE_STR("\033]2;Terminology\007");
ty->prop.title = eina_stringshare_add(s);
free(s);
}
else
{
s = eina_unicode_unicode_to_utf8(p, &len);
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
if (s)
{
ty->prop.title = eina_stringshare_add(s);
free(s);
}
else
{
ty->prop.title = NULL;
}
if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
ty->prop.title = NULL;
}
if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
break;
case 4:
if (!*p)

View File

@ -14,3 +14,6 @@ cursor-shape-5.sh 21332951c006a2d91cf0f227758ff477
cursor-shape-6.sh 21332951c006a2d91cf0f227758ff477
cursor-shape-7.sh 5d0dadf7273d918cbcd99df95e56795e
tabs.sh 960b74686e23e8e39c3446768b9efc75
xterm-osc-0-title-icon.sh cb5080cc1dbc23b553b62fbdc8cbdf68
xterm-osc-1-icon.sh 9202db6e81ce810f007035770934fecb
xterm-osc-2-title.sh 49a058f1813bdd64faab1cf1af3ebe09

19
tests/xterm-osc-0-title-icon.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# fill space with E
printf '\033#8'
#set color
printf '\033[46;31;3m'
# set title + icon
printf '\033]0;echo "fail"\n\007'
# query title + icon, and device attributes
printf '\033]0;?\007\033[>c'
# set again title + icon
printf '\033]0;title-icon-v2\007'
# set empty
printf '\033]0;\007'

19
tests/xterm-osc-1-icon.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# fill space with E
printf '\033#8'
#set color
printf '\033[46;31;3m'
# set icon
printf '\033]1;echo "fail"\n\007'
# query icon, and device attributes
printf '\033]1;?\007\033[>c'
# set again icon
printf '\033]1;icon-v2\007'
# set empty
printf '\033]1;\007'

19
tests/xterm-osc-2-title.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# fill space with E
printf '\033#8'
#set color
printf '\033[46;31;3m'
# set title
printf '\033]2;echo "fail"\n\007'
# query title, and device attributes
printf '\033]2;?\007\033[>c'
# set again title
printf '\033]2;title-v2\007'
# set empty
printf '\033]2;\007'