Skip to content

Commit

Permalink
fix: ignore invalid XTGETTCAP responses
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Sep 12, 2024
1 parent 4fa1f06 commit d1827e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,14 @@ func parseDcs(b []byte) (int, Msg) {
case 'r' | '+'<<parser.IntermedShift:
// XTGETTCAP responses
switch param := dcs.Param(0); param {
case 0, 1:
case 1: // 1 means valid response, 0 means invalid response
tc := parseTermcap(b[start:end])
// XXX: some terminals like KiTTY report invalid responses with
// their queries i.e. sending a query for "Tc" using "\x1bP+q5463\x1b\\"
// returns "\x1bP0+r5463\x1b\\".
// The specs says that invalid responses should be in the form of
// DCS 0 + r ST "\x1bP0+r\x1b\\"
// We ignore invalid responses and only send valid ones to the program.
//
// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
return i, tc
Expand Down

0 comments on commit d1827e4

Please sign in to comment.