This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit 2c7a7edaba623a7df37c7055ccde28b32d0d7253
Author: Boris Faure <[email protected]>
AuthorDate: Wed Nov 4 22:04:50 2026 +0000

    termptyesc: wait for a split ESC \ at the end of the DCS buffer
    
    When the ESC of the ESC \ ending a DCS fell on the last codepoint of
    both a read and the DCS buffer, the DCS was taken for an overflowing
    one and dropped: a DECRQSS of that length got no reply read 1 or 2
    bytes at a time. The OSC scanner already waits for the next read
    there.
---
 src/bin/termptyesc.c     | 14 +++++++-------
 tests/dcs-full-buffer.sh | 38 ++++++++++++++++++++++++++++++++++++++
 tests/tests.results      |  1 +
 3 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index c31a1813..d22d123b 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -6035,13 +6035,6 @@ _handle_esc_dcs(Termpty *ty,
         b++;
         cc++;
      }
-   if (b == be)
-     {
-        WRN("DCS longer than %d codepoints, discarding it", (int)(be - buf));
-        ty->dcs_skip = 1;
-        len = cc - c;
-        goto end;
-     }
    if (cc == ce)
      {
         /* the last codepoint may be the ESC of a split ESC \ */
@@ -6049,6 +6042,13 @@ _handle_esc_dcs(Termpty *ty,
           cc--;
         return _seq_incomplete(ty, c, cc);
      }
+   if (b == be)
+     {
+        WRN("DCS longer than %d codepoints, discarding it", (int)(be - buf));
+        ty->dcs_skip = 1;
+        len = cc - c;
+        goto end;
+     }
    if (scanned)
      memcpy(buf, c, scanned * sizeof(Eina_Unicode));
    *b = 0;
diff --git a/tests/dcs-full-buffer.sh b/tests/dcs-full-buffer.sh
new file mode 100755
index 00000000..12dfc041
--- /dev/null
+++ b/tests/dcs-full-buffer.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# shellcheck source=tests/utils.sh
+. "$(dirname "$0")/utils.sh"
+
+# $1: the number of spaces to print
+spaces()
+{
+    head -c "$1" /dev/zero | tr '\0' ' '
+}
+
+# clear screen
+printf '\033[2J'
+
+# move to 0; 0
+printf '\033[0;0H'
+
+# a DECRQSS whose ESC \ starts on the last codepoint of the DCS buffer: it
+# is still a request, answered as invalid
+printf '\033P$q'
+spaces 4092
+printf 'm\033\\'
+printf 'A'
+
+# a codepoint more and the DCS overflows: it is discarded up to its ST
+printf '\033P$q'
+spaces 4094
+printf 'm\033\\'
+printf 'B'
+
+# a long sixel image, ignored
+printf '\033Pq'
+i=0
+while [ $i -lt 100 ]; do
+    printf '#0;2;0;0;0#0~~@@vv@@~~$-'
+    i=$((i + 1))
+done
+printf '\033\\'
+printf 'C'
diff --git a/tests/tests.results b/tests/tests.results
index bc9c5d4c..a5ef5064 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -209,4 +209,5 @@ dcs-long.sh 56028fb44070f1bf64f323f751f0d79a
 backlog-long-line.sh f4423fa1c7069b9bf8a62045cc97dda3
 ty-escape-long.sh 83d61b472b818eb3d699021e14e45452
 csi-c0.sh 68f5a8be4feacac8b7b8d4d5b9b026af
+dcs-full-buffer.sh f4cb1513ca59539f373e8d389e6ac01d
 osc-long.sh a94cb70dd58d07f52bbdf0cc5e7b95e1

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to