From cc10b68d313ec9e10e3186c4c953d2699f7de079 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 12 May 2022 18:01:42 +0100 Subject: [PATCH] Allow BEL to terminate OSC sequences during setup. This is a partial cherry-pick of commit de66b0313a23d04 from main, which allows all the forms of OSC sequence termination to apply in the preliminary states as well as OSC_STRING. The reporting user only mentioned the case of OSC 112 BEL, and not the various forms of ST. So the former is actually known to be occurring in the wild, and is also the least complicated part of the full patch on main. Therefore I think this part is worthwhile and reasonably safe to cherry-pick to 0.77 just before a release, whereas I'd be uncomfortable making the rest of the changes at this late stage. --- terminal/terminal.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/terminal/terminal.c b/terminal/terminal.c index ae5e4144..59a3a96a 100644 --- a/terminal/terminal.c +++ b/terminal/terminal.c @@ -3822,6 +3822,19 @@ static void term_out(Terminal *term, bool called_from_term_data) } break; case '\007': { /* BEL: Bell */ + if (term->termstate == SEEN_OSC || + term->termstate == SEEN_OSC_W) { + /* + * In an OSC context, BEL is one of the ways to terminate + * the whole sequence. We process it as such even if we + * haven't got into the final OSC_STRING state yet, so that + * OSC sequences without a string will be handled cleanly. + */ + do_osc(term); + term->termstate = TOPLEVEL; + break; + } + struct beeptime *newbeep; unsigned long ticks;