Fix SGR handler treating prefixed CSI sequences (e.g. XTMODKEYS) as SGR - #232
Open
smohekey wants to merge 1 commit into
Open
Fix SGR handler treating prefixed CSI sequences (e.g. XTMODKEYS) as SGR#232smohekey wants to merge 1 commit into
smohekey wants to merge 1 commit into
Conversation
`_csiHandleSgr` runs for any CSI ending in `m`, ignoring the private prefix. Real SGR is `CSI Ps m` and never has a prefix, but sequences that share the `m` final byte and carry a prefix are not SGR — notably XTMODKEYS `CSI > 4 ; 2 m` (set modifyOtherKeys), which many terminals and TUI apps emit on startup. Because the handler read its parameters `[4, 2]` as SGR codes, `4` switched on underline for every following cell — the whole screen appears underlined until reset. Bail out of the SGR handler when the CSI has a private prefix so only genuine `CSI Ps m` toggles graphic rendition. Verified `\e[4m` / `\e[24m` and combined sequences like `\e[4;38;5;208m` still render underline correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
EscapeParser._csiHandleSgrruns for any CSI ending inm, ignoring the private prefix that was parsed into_csi.prefix. Real SGR isCSI Ps mand never carries a prefix, but several sequences share themfinal byte while carrying a prefix and are not SGR — most notably XTMODKEYSCSI > Ps ; Ps m(set modifyOtherKeys), which many terminals and TUI apps emit on startup/attach.Because the handler reads such a sequence's parameters as SGR codes,
CSI > 4 ; 2 m(\e[>4;2m) is interpreted as SGR4(underline on) +2(faint), so the entire screen becomes underlined until something resets it.Reproduce
This is easy to miss because the sequence is often split across read chunks and only emitted on some attaches, so it presents as intermittent.
Fix
Bail out of
_csiHandleSgrwhen the CSI has a private prefix, so only genuineCSI Ps mtoggles graphic rendition. Genuine underlining is unaffected — verified\e[4m/\e[24mand combined\e[4;38;5;208mstill render underline correctly.