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

git pushed a commit to branch master
in repository terminology.

View the commit online.

commit b31eced3a862f5cb64c31099e1379f54705072d7
Author: Boris Faure <[email protected]>
AuthorDate: Sat Sep 19 16:19:19 2026 +0000

    tytest: checksum and dump the OSC 7 working directory
---
 src/bin/tytest.c         | 11 +++++++++++
 tests/tests.results      |  1 +
 tests/xterm-osc-7-cwd.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)

diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 94400af5..05e32537 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -246,6 +246,16 @@ _tytest_checksum(Termpty *ty)
      {
         MD5Update(&ctx, (unsigned char const*)"(NULL)", 6);
      }
+   /* Working directory. Hashed only when set, with no "(NULL)" sentinel, so
+    * that the byte stream is unchanged for every test that never sends
+    * OSC 7. An empty value is rejected at parse time, so "unset" and "set to
+    * empty" cannot be confused. */
+   if (ty->prop.cwd)
+     {
+        MD5Update(&ctx,
+                  (unsigned char const*)ty->prop.cwd,
+                  strlen(ty->prop.cwd));
+     }
    /* Cursor shape */
    const char *cursor_shape = tytest_cursor_shape_get();
    MD5Update(&ctx, (unsigned char const*)cursor_shape,
@@ -390,6 +400,7 @@ _tytest_dump(Termpty *ty)
           (int)ty->termstate.restrict_cursor);
    printf("title=%s\n", ty->prop.title ? ty->prop.title : "(NULL)");
    printf("icon=%s\n", ty->prop.icon ? ty->prop.icon : "(NULL)");
+   printf("cwd=%s\n", ty->prop.cwd ? ty->prop.cwd : "(NULL)");
 
    backlog_len = termpty_backlog_length(ty);
    printf("backlog rows=%d\n", (int)backlog_len);
diff --git a/tests/tests.results b/tests/tests.results
index 1e0d4d6f..b742ffdf 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -21,6 +21,7 @@ tabs.sh 08ffb95c74fc9ce323b09f60b125526d
 xterm-osc-0-title-icon.sh 5109e84f8640e64ced6bc9fdfa85d321
 xterm-osc-1-icon.sh 1859eb51e97f2bfdd00a347979694596
 xterm-osc-2-title.sh df4151925c192970873ac03101294ee6
+xterm-osc-7-cwd.sh cc335e6d5aa3bf74f8549e4fe1a079a7
 dsr-cpr.sh 01e0e1617b520454065d6b5b6a7383cd
 dsr-dir.sh 8fec9b3816ad08c12b228a34c00f006a
 dsr-kbd.sh e8f5f8372bc8da468d5ddcd7e1742628
diff --git a/tests/xterm-osc-7-cwd.sh b/tests/xterm-osc-7-cwd.sh
new file mode 100755
index 00000000..99aad53a
--- /dev/null
+++ b/tests/xterm-osc-7-cwd.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# fill space with E
+printf '\033#8'
+
+# The checksum is of the final state, so every rejected form goes first and
+# proves itself by not disturbing the known-good value set at the end.
+
+# not a file:// URI
+printf '\033]7;http://localhost/tmp\033\\'
+
+# no path at all
+printf '\033]7;file://localhost\007'
+
+# an empty payload clears the directory rather than being an error: that is
+# what tmux sends for a pane that has none. Invisible to the checksum, which
+# cannot tell "cleared" from "never set", so it is verified by --dump.
+printf '\033]7;\007'
+
+# a host that is not ours: ignored, and deliberately not an error
+printf '\033]7;file://not-this-host.invalid/tmp/elsewhere\033\\'
+
+# a control character smuggled in through the percent-encoding
+printf '\033]7;file:///tmp/a%%07b\033\\'
+
+# Longer than PATH_MAX once decoded. Percent-decoding only ever shortens and
+# the OSC payload is capped at 4096 Eina_Unicode, so multibyte expansion is the
+# only way to reach the cap: 1120 characters of U+1D11E, 4 bytes each.
+pad=''
+i=0
+while [ $i -lt 40 ]; do
+    pad="$pad𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞"
+    i=$((i + 1))
+done
+# On stderr, which the checksum never sees: if PATH_MAX ever exceeds the byte
+# count the sequence stops being rejected and this case quietly stops biting.
+printf 'PATH_MAX=%s, oversized path is %s bytes\n' \
+       "$(getconf PATH_MAX /)" \
+       "$(printf '%s' "$pad" | wc -c | tr -d ' ')" >&2
+printf '\033]7;file:///%s\033\\' "$pad"
+
+# accepted: empty host, localhost, and percent-decoding. The last one wins.
+printf '\033]7;file:///tmp/valid\033\\'
+printf '\033]7;file://localhost/tmp/valid-2\007'
+printf '\033]7;file:///tmp/a%%20b\033\\'

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

Reply via email to