21d434d2dbadf91d7bd2089ca1ca92c2d918b114 attempted to ignore unknown CSI sequences with a specific termination rule. This however does not apply to mouse CSI sequences which can have characters out of that range. Fix this by throwing away the whole sequence when an unhandled mouse sequence is detected.
Unified · Split
| @@ -240,6 +240,13 @@ static void process_input(struct input_ctx *input_ctx, bool timeout) · 239 unmodified lines | |||
| 240 | int mods = 0; | 240 | int mods = 0; |
| 241 | if (buf.b[0] == '\033') { | 241 | if (buf.b[0] == '\033') { |
| 242 | if (buf.len > 1 && buf.b[1] == '[') { | 242 | if (buf.len > 1 && buf.b[1] == '[') { |
| 243 | // Throw away unrecognized mouse CSI sequences. | ||
| 244 | // Cannot be handled by the loop below since the bytes | ||
| 245 | // afterwards can be out of that range. | ||
| 246 | if (buf.len > 2 && buf.b[2] == 'M') { | ||
| 247 | skip_buf(&buf, buf.len); | ||
| 248 | continue; | ||
| 249 | } | ||
| 243 | // unknown CSI sequence. wait till it completes | 250 | // unknown CSI sequence. wait till it completes |
| 244 | for (int i = 2; i < buf.len; i++) { | 251 | for (int i = 2; i < buf.len; i++) { |
| 245 | if (buf.b[i] >= 0x40 && buf.b[i] <= 0x7E) { | 252 | if (buf.b[i] >= 0x40 && buf.b[i] <= 0x7E) { |