Tighten up Device Attributes reply parsing - #234
Open
pR0Ps wants to merge 1 commit into
Open
Conversation
This fixes an issue where `civis`/`cnorm` (hide/show cursor) escape sequences with `TERM=linux` were being parsed as requests to send a DA1 response, leading to repeated streams of `1;2c1;2c1;`... being shown in the terminal when using programs like `vim`, `tmux`, etc. where showing/hiding the cursor is common. The issue stems from the fact that under `TERM=linux`, the `civis`/`cnorm` escape sequences each end with a Linux console cursor size sequence (`CSI ? 1c`/`CSI ? 0c`) appended after the standard show/hide sequence. Since these cursor shape sequences match the `CSI <anything> c` pattern, they're handled as device attribute requests by `_csiHandleSendDeviceAttributes()`, which would respond to them with a DA1 sequence by default because `?` isn't a valid prefix. Example sequences: ``` $ TERM=xterm tput civis | xxd 00000000: 1b5b 3f32 356c .[?25l $ TERM=xterm tput cnorm | xxd 00000000: 1b5b 3f31 326c 1b5b 3f32 3568 .[?12l.[?25h $ TERM=linux tput civis | xxd 00000000: 1b5b 3f32 356c 1b5b 3f31 63 .[?25l.[?1c $ TERM=linux tput cnorm | xxd 00000000: 1b5b 3f32 3568 1b5b 3f30 63 .[?25h.[?0c ``` This commit updates the DA reply parsing to only accept valid prefixes (nothing, `>`, or `=`) and let everything else fall into the default case so it's ignored.
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.
This fixes an issue where
civis/cnorm(hide/show cursor) escape sequences withTERM=linuxwere being parsed as requests to send a DA1 response, leading to repeated streams of1;2c1;2c1;... being shown in the terminal when using programs likevim,tmux, etc. where showing/hiding the cursor is common.The issue stems from the fact that under
TERM=linux, thecivis/cnormescape sequences each end with a Linux console cursor size sequence (CSI ? 1c/CSI ? 0c) appended after the standard show/hide sequence. Since these cursor shape sequences match theCSI <anything> cpattern, they're handled as device attribute requests by_csiHandleSendDeviceAttributes(), which would respond to them with a DA1 sequence by default because?isn't a valid prefix.Example sequences:
This commit updates the DA reply parsing to only accept valid prefixes (nothing,
>, or=) and let everything else fall into the default case so it's ignored.