From d848a9499830c530e804a41ffd8aa1bc942fa735 Mon Sep 17 00:00:00 2001 From: Sam Leonard Date: Tue, 27 Feb 2024 16:08:09 +0000 Subject: [PATCH] shared/ptyfwd: detect String Terminator or BEL when parsing an OSC sequence --- src/shared/ptyfwd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c index bf775425e78..17c1549132e 100644 --- a/src/shared/ptyfwd.c +++ b/src/shared/ptyfwd.c @@ -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 */ + /* Otherwise, the OSC sequence is over + * + * There are two allowed ways to end an OSC sequence: + * BEL '\x07' + * String Terminator (ST): \ - "\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') { + if (c == '\x07' || c == '\x1b') { r = insert_window_title_fix(f, i+1); if (r < 0) return r;