billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=479d96e5dc652b30e2993e63a5191e4b599d3d9b

commit 479d96e5dc652b30e2993e63a5191e4b599d3d9b
Author: Boris Faure <[email protected]>
Date:   Sun Dec 9 16:06:42 2018 +0100

    termptyesc: act like xterm, do not report title/icon-name
---
 src/bin/termptyesc.c            | 82 +++++++++++++++--------------------------
 tests/tests.results             |  3 ++
 tests/xterm-osc-0-title-icon.sh | 19 ++++++++++
 tests/xterm-osc-1-icon.sh       | 19 ++++++++++
 tests/xterm-osc-2-title.sh      | 19 ++++++++++
 5 files changed, 89 insertions(+), 53 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index d4d46d1..fb78cc5 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 abd4bec..c9a8fe1 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 0000000..b3be7a1
--- /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 0000000..461f9c7
--- /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 0000000..fedb237
--- /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'
+

-- 


Reply via email to