diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index d4d46d1f..fb78cc5f 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -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) diff --git a/tests/tests.results b/tests/tests.results index abd4bec9..c9a8fe16 100644 --- a/tests/tests.results +++ b/tests/tests.results @@ -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 diff --git a/tests/xterm-osc-0-title-icon.sh b/tests/xterm-osc-0-title-icon.sh new file mode 100755 index 00000000..b3be7a1d --- /dev/null +++ b/tests/xterm-osc-0-title-icon.sh @@ -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' + diff --git a/tests/xterm-osc-1-icon.sh b/tests/xterm-osc-1-icon.sh new file mode 100755 index 00000000..461f9c79 --- /dev/null +++ b/tests/xterm-osc-1-icon.sh @@ -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' + diff --git a/tests/xterm-osc-2-title.sh b/tests/xterm-osc-2-title.sh new file mode 100755 index 00000000..fedb2374 --- /dev/null +++ b/tests/xterm-osc-2-title.sh @@ -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' +