InputParser misses ESC ESC \ in discard/SOS/PM/APC states and 0x9C in OSC statesInputParser string statesSeverity: HIGH
Status: ✅ RESOLVED
Files: src/input.zig:350-402, src/input.zig:537-543, src/input.zig:632-638
ESC ESC \ fails to terminate osc_discard, dcs_discard, and sos_pm_apc (src/input.zig:400,541,636):
Bug #388 fixed advanceOscEsc and advanceDcsSixelEsc so that receiving 0x1B while already in the *_esc state remains in *_esc, allowing ESC ESC \ to terminate the string. However, the remaining three *_esc handlers were missed:
fn advanceOscDiscardEsc(self: *InputParser, byte: u8) void {
switch (byte) {
'\\' => self.state = .ground,
0x18, 0x1A => self.state = .ground,
else => self.state = .osc_discard,
}
}
(advanceDcsDiscardEsc at line 537 and advanceSosPmApcEsc at line 632 have the identical else => transition.) When a payload inside osc_discard, dcs_discard, or sos_pm_apc ends with ESC immediately before the ESC \ terminator (0x1B 0x1B 0x5C), the second 0x1B transitions back to the non-ESC state and the \ is consumed as payload, leaving the parser stuck discarding subsequent terminal output until another terminator arrives.
0x9C) ignored in advanceOsc and advanceOscDiscard (src/input.zig:350-394):
advanceGround (src/input.zig:231) enters .osc_string on 0x9D (C1 8-bit OSC), and advanceDcsSixel, advanceDcsDiscard, and advanceSosPmApc all terminate on 0x9C (C1 8-bit ST). However, neither advanceOsc nor advanceOscDiscard checks for 0x9C, so an 8-bit OSC sequence (0x9D ... 0x9C) never terminates on 0x9C and instead appends 0x9C to osc_buf.0x1B => {}, to advanceOscDiscardEsc, advanceDcsDiscardEsc, and advanceSosPmApcEsc.0x9C in advanceOsc (dispatching self.dispatchOsc() and returning to .ground) and in advanceOscDiscard (transitioning to .ground).