commit 100747f56b16cba1b2fbf3d5f05bd13aac43103f
parent d7b2b55bf5cce237b39a83143ad49ea48a5611d2
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 10 Aug 2020 16:08:17 +0200
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.
Diffstat:
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -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);