mirror of https://github.com/MidnightCommander/mc
This change prevents misinterpreting an unknown ESC sequence's
tail as a garbage input. To reproduce, run "sleep 3" and hold down Down_Arrow key until sleep runs. With debugging log enabled, the following can be seen: entered get_key_code(no_delay:0) c=tty_lowlevel_getch()=27 push_char(27) !0 c=xgetch_second()=91 push_char(91) !0 2 c=tty_lowlevel_getch()=66 push_char(66) seq_buffer[0]:27 <---- the saved Down Arrow sequence "ESC [ B" seq_buffer[1]:91 seq_buffer[2]:66 seq_buffer[3]:0 pending_keys!=NULL. m=-1 d=*pending_keys++=27 d=ALT(*pending_keys++)=ALT(91)=8283 ^^^^^^^^^^^^^^^^^^^^^^^ we misinterpret "ESC [ B" as "ESC [" return correct_key_code(8283) entered get_key_code(no_delay:0) pending_keys!=NULL. m=-1 d=*pending_keys++=66 ^^^^^^^^^^^^ we think user pressed "B" return correct_key_code(66) With this patch, no bogus "input" is generated. Longer unknown sequences need an additional fix, coming next. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
77cfaf03cb
commit
ecd3b62b8e
|
@ -1747,14 +1747,19 @@ get_key_code (int no_delay)
|
|||
if (pending_keys != NULL)
|
||||
{
|
||||
int d;
|
||||
gboolean bad_seq;
|
||||
|
||||
d = *pending_keys++;
|
||||
while (d == ESC_CHAR)
|
||||
d = ALT (*pending_keys++);
|
||||
|
||||
if (*pending_keys == '\0')
|
||||
bad_seq = (*pending_keys != ESC_CHAR && *pending_keys != 0);
|
||||
if (*pending_keys == '\0' || bad_seq)
|
||||
pending_keys = seq_append = NULL;
|
||||
|
||||
if (bad_seq)
|
||||
goto nodelay_try_again;
|
||||
|
||||
if (d > 127 && d < 256 && use_8th_bit_as_meta)
|
||||
d = ALT (d & 0x7f);
|
||||
|
||||
|
@ -1835,7 +1840,7 @@ get_key_code (int no_delay)
|
|||
{
|
||||
if (c == this->ch)
|
||||
{
|
||||
if (!this->child)
|
||||
if (this->child == NULL)
|
||||
{
|
||||
/* We got a complete match, return and reset search */
|
||||
int code;
|
||||
|
|
Loading…
Reference in New Issue