szn

Bug 429 — DCS ‘$ q’ (DECRQSS) misrouted to the sixel parser

429. DCS ‘$ q’ (DECRQSS) misrouted to the sixel parser

Severity: HIGH Status: Fixed

The DCS intermediate parser flips dcs_is_sixel on the final byte q regardless of the intermediate bytes. Both sixel (ESC P q) and DECRQSS (ESC P $ q) end in q, but only sixel should set the sixel flag.

// src/input.zig:459-476
fn advanceDcsIntermediate(self: *InputParser, byte: u8) Error!void {
    switch (byte) {
        0x20...0x2F => {},
        'q' => {
            self.dcs_is_sixel = true; // ANY DCS ending in 'q' → sixel
            self.dcs_buf.clearRetainingCapacity();
            try self.dcs_buf.appendSlice(self.screen.allocator, "\x1bPq");
            self.state = .dcs_sixel;
        },

Problem & Impact

Reference Behavior

tmux/sixel spec: a DCS sixel starts with ESC P + optional params + q; DECRQSS starts with ESC P $ q. The $ (0x24) intermediate delimiter must be present before treating the sequence as sixel.

Proposed Fix

Track the presence of the $ intermediate in the DCS body and only set dcs_is_sixel when the final byte is q and no $ delimiter preceded it (i.e. route ESC P $ q to DECRQSS handling instead).