Skip to content

Tighten up Device Attributes reply parsing - #8

Open
pR0Ps wants to merge 1 commit into
gwitko:masterfrom
pR0Ps:bugfix/da1
Open

Tighten up Device Attributes reply parsing#8
pR0Ps wants to merge 1 commit into
gwitko:masterfrom
pR0Ps:bugfix/da1

Conversation

@pR0Ps

@pR0Ps pR0Ps commented Jul 28, 2026

Copy link
Copy Markdown

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.

I have also created a PR in the upstream project (TerminalStudio#234), but since it looks a little inactive and your Conduit project is where I'm actually encountering the issue, I figured I would submit it here as well.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant