1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Allow terminating OSC sequences during setup.

A user reports that the xterm OSC 112 sequence (reset cursor colour)
is sometimes sent as simply OSC 112 BEL, rather than OSC 112 ; BEL.
When xterm parses this, the BEL still acts as an OSC terminator, even
though it appears before the separating semicolon that shifts into the
'absorb the notional command string' state.

PuTTY doesn't support that sequence at all. But currently, the way it
doesn't support it is by treating the BEL completely normally, so that
you get an annoying beep when a client application sends that
abbreviated sequence.

Now we recognise all the OSC terminator sequences even in the OSC
setup termstates, as well as the final OSC_STRING state. That goes
equally for BEL, ST in the form of ESC \, ST in the form of
single-byte 0x9C, and ST in the UTF-8 encoding.
This commit is contained in:
Simon Tatham 2022-05-11 20:07:31 +01:00
parent e9de549e7e
commit de66b0313a

View File

@ -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;
@ -3907,7 +3920,11 @@ static void term_out(Terminal *term, bool called_from_term_data)
case '\033': /* ESC: Escape */
if (term->vt52_mode)
term->termstate = VT52_ESC;
else {
else if (term->termstate == SEEN_OSC ||
term->termstate == SEEN_OSC_W) {
/* Be prepared to terminate an OSC early */
term->termstate = OSC_MAYBE_ST;
} else {
compatibility(ANSIMIN);
term->termstate = SEEN_ESC;
term->esc_query = 0;
@ -5156,6 +5173,17 @@ static void term_out(Terminal *term, bool called_from_term_data)
else
term->esc_args[term->esc_nargs-1] = UINT_MAX;
break;
case 0x9C:
/* Terminate even though we aren't in OSC_STRING yet */
do_osc(term);
term->termstate = TOPLEVEL;
break;
case 0xC2:
if (in_utf(term)) {
/* Or be prepared for the UTF-8 version of that */
term->termstate = OSC_MAYBE_ST_UTF8;
}
break;
default:
/*
* _Most_ other characters here terminate the
@ -5325,6 +5353,17 @@ static void term_out(Terminal *term, bool called_from_term_data)
else
term->esc_args[0] = UINT_MAX;
break;
case 0x9C:
/* Terminate even though we aren't in OSC_STRING yet */
do_osc(term);
term->termstate = TOPLEVEL;
break;
case 0xC2:
if (in_utf(term)) {
/* Or be prepared for the UTF-8 version of that */
term->termstate = OSC_MAYBE_ST_UTF8;
}
break;
default:
term->termstate = OSC_STRING;
term->osc_strlen = 0;