diff options
author | nanahi <130121847+na-na-hi@users.noreply.github.com> | 2024-03-02 01:36:18 -0500 |
---|---|---|
committer | Kacper Michajłow <kasper93@gmail.com> | 2024-04-18 01:03:33 +0200 |
commit | cbc3fb104d9b6e6b034fd6a7f8645bb4f7615327 (patch) | |
tree | 0d47122045d98e5acb6ebbad7180a581f7ef250e /osdep | |
parent | 9ae58ba186ca58b80f0453e76c75015f471beb05 (diff) | |
download | mpv-cbc3fb104d9b6e6b034fd6a7f8645bb4f7615327.tar.bz2 mpv-cbc3fb104d9b6e6b034fd6a7f8645bb4f7615327.tar.xz |
terminal-unix: ignore unhandled mouse CSI sequences
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.
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/terminal-unix.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index e738aec454..faa11e0a2f 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -240,6 +240,13 @@ static void process_input(struct input_ctx *input_ctx, bool timeout) int mods = 0; if (buf.b[0] == '\033') { if (buf.len > 1 && buf.b[1] == '[') { + // Throw away unrecognized mouse CSI sequences. + // Cannot be handled by the loop below since the bytes + // afterwards can be out of that range. + if (buf.len > 2 && buf.b[2] == 'M') { + skip_buf(&buf, buf.len); + continue; + } // unknown CSI sequence. wait till it completes for (int i = 2; i < buf.len; i++) { if (buf.b[i] >= 0x40 && buf.b[i] <= 0x7E) { |