From 4dcbd40c49532842ce25918f5335573eeb8c0327 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 26 Dec 2019 13:53:48 +0100 Subject: [PATCH] input: consume and ignore the raw escape sequences for F17 to F24 When --rawsequences is used, consume the full escape sequences for the F17 to F24 function keys (on xterm-compatible terminals and on the Linux console), to prevent them entering junk into the buffer. This fixes https://savannah.gnu.org/bugs/?57483. --- src/winio.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/winio.c b/src/winio.c index ead7a1f9..c9147f96 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1068,7 +1068,9 @@ int convert_sequence(const int *seq, size_t length, int *consumed) #endif } /* ->->->->->->-> */ - } + } else if (length > 5 && seq[3] == ';' && seq[5] == '~') + /* Esc [ 1 n ; 2 ~ == F17...F20 on some terminals. */ + *consumed = 6; break; case '2': if (length > 3 && seq[3] == '~') { @@ -1100,6 +1102,9 @@ int convert_sequence(const int *seq, size_t length, int *consumed) else if (length > 4 && seq[2] == ';' && seq[4] == '~') /* Esc [ 2 ; x ~ == modified Insert on xterm. */ *consumed = 5; + else if (length > 5 && seq[3] == ';' && seq[5] == '~') + /* Esc [ 2 n ; 2 ~ == F21...F24 on some terminals. */ + *consumed = 6; break; case '3': /* Esc [ 3 ~ == Delete on VT220/VT320/ * Linux console/xterm/Terminal. */ @@ -1132,6 +1137,9 @@ int convert_sequence(const int *seq, size_t length, int *consumed) if (length > 2 && seq[2] == '@') /* Esc [ 3 @ == Ctrl-Shift-Delete on urxvt. */ return controlshiftdelete; + if (length > 3 && seq[3] == '~') + /* Esc [ 3 n ~ == F17...F20 on some terminals. */ + *consumed = 4; #endif break; case '4': /* Esc [ 4 ~ == End on VT220/VT320/ @@ -1321,7 +1329,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput) * (the longest possible escape sequence) from the keybuffer and * translate the sequence into its corresponding keycode. */ put_back(kbinput); - length = (key_buffer_len < 5 ? key_buffer_len : 5); + length = (key_buffer_len < 6 ? key_buffer_len : 6); sequence = get_input(NULL, length); retval = convert_sequence(sequence, length, &consumed);