]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/ptyfwd: detect String Terminator or BEL when parsing an OSC sequence 31514/head
authorSam Leonard <sam.leonard@codethink.co.uk>
Tue, 27 Feb 2024 16:08:09 +0000 (16:08 +0000)
committerSam Leonard <sam.leonard@codethink.co.uk>
Wed, 28 Feb 2024 11:50:18 +0000 (11:50 +0000)
src/shared/ptyfwd.c

index bf775425e78be8fbb2475df056d7956012e4bb92..17c1549132ead45b7dea0f23f89230a6f28ac34e 100644 (file)
@@ -507,9 +507,15 @@ static int pty_forward_ansi_process(PTYForward *f, size_t offset) {
                                 } else if (!strextend(&f->osc_sequence, CHAR_TO_STR(c)))
                                         return -ENOMEM;
                         } else {
-                                /* Otherwise, the OSC sequence is over */
-
-                                if (c == '\x07') {
+                                /* Otherwise, the OSC sequence is over
+                                 *
+                                 * There are two allowed ways to end an OSC sequence:
+                                 * BEL '\x07'
+                                 * String Terminator (ST): <Esc>\ - "\x1b\x5c"
+                                 * since we cannot lookahead to see if the Esc is followed by a \
+                                 * we cut a corner here and assume it will be \. */
+
+                                if (c == '\x07' || c == '\x1b') {
                                         r = insert_window_title_fix(f, i+1);
                                         if (r < 0)
                                                 return r;