verbatim: discard entire keystroke when it's not valid for Unicode Input

This will not work for the deviant escape sequences for F1 to F5
on the Linux console nor for Alt+arrow on urxvt and such, but...
I can't be bothered to handle those too.

This fixes https://savannah.gnu.org/bugs/?58929.

Bug existed since commit be203832 from earlier today.
This commit is contained in:
Benno Schulenberg 2020-08-10 16:08:17 +02:00
parent d7b2b55bf5
commit 100747f56b
1 changed files with 13 additions and 2 deletions

View File

@ -1391,12 +1391,15 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
char *multibyte;
reveal_cursor = FALSE;
linger_after_escape = TRUE;
while (unicode == PROCEED) {
keycode = get_input(win);
unicode = assemble_unicode(keycode);
}
linger_after_escape = FALSE;
if (keycode == KEY_WINCH) {
*count = 999;
free(yield);
@ -1404,9 +1407,17 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
}
/* For an invalid digit, discard its possible continuation bytes. */
if (unicode == INVALID_DIGIT)
while (key_buffer_len > 0 && 0x7F < *key_buffer && *key_buffer < 0xC0)
if (unicode == INVALID_DIGIT) {
if (keycode == ESC_CODE) {
get_input(NULL);
while (key_buffer_len > 0 && 0x1F < *key_buffer && *key_buffer < 0x40)
get_input(NULL);
if (key_buffer_len > 0 && 0x3F < *key_buffer && *key_buffer < 0x7F)
get_input(NULL);
} else if (0xC0 <= keycode && keycode <= 0xFF)
while (key_buffer_len > 0 && 0x7F < *key_buffer && *key_buffer < 0xC0)
get_input(NULL);
}
/* Convert the Unicode value to a multibyte sequence. */
multibyte = make_mbchar(unicode, (int *)count);