Running

        printf '\033P+q696e646e\033\\'; cat -v

inside screen will echo "+q696e646e".

This seems wrong; this particular sequence is an XTGETTCAP command,
an XTerm extension.

Git blame doesn't say why screen forwards the DCS payload.  My guess
is that this is to allow the user to forward escape sequences to the
underlying terminal, e.g.:

        printf '\033P\033[A\033\\'; cat -v

This example is contrived because screen does support \033[A, but there
may be other commands that are understood by the parent terminal but
not by screen.

Let's ignore DCS sequences unless they start with a control character.
---
 src/ansi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/ansi.c b/src/ansi.c
index 9ee4ffa..d081860 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -30,6 +30,7 @@
 
 #include "ansi.h"
 
+#include <ctype.h>
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
@@ -1314,7 +1315,8 @@ static int StringEnd(Window *win)
                }
                return -1;
        case DCS:
-               LAY_DISPLAYS(&win->w_layer, AddStr(win->w_string));
+               if (iscntrl(win->w_string[0]))
+                       LAY_DISPLAYS(&win->w_layer, AddStr(win->w_string));
                break;
        case AKA:
                if (win->w_title == win->w_akabuf && !*win->w_string)
-- 
2.49.0


Reply via email to