cli: Consume invalid escape sequences early
PATCH 1/1 cli: Consume invalid escape sequences early
This commit fixes some issues with extra 'Esc' keys entered by user:
1. Sequence <Esc><Esc><Enter> right after autoboot stop gives:
=>
nknown command 'ry 'help'
=>
2. Sequence <Esc><p><r><i><Enter> gives:
=> ri
Unknown command 'ri' - try 'help'
=>
3. Extra 'Esc' key presses break backspace functionality.
--- common/cli_getch.c | 2 ++ 1 file changed, 2 insertions(+)
common/cli_getch.c +2 -0
@@ -46,6 +46,8 @@ static int cli_ch_esc(struct cli_ch_state *cch, int ichar,case 1 :if (ichar =='[' || ichar =='O' ) act =ESC_SAVE ; +else + act =ESC_CONVERTED ;break ;case 2 :switch (ichar) {
Signature · 1 line
2.34.1
Hi Yurii,
Quoted 32 lines · Yurii Monakov
This commit fixes some issues with extra 'Esc' keys entered by user:
1. Sequence <Esc><Esc><Enter> right after autoboot stop gives:
=>
nknown command 'ry 'help'
=>
2. Sequence <Esc><p><r><i><Enter> gives:
=> ri
Unknown command 'ri' - try 'help'
=>
3. Extra 'Esc' key presses break backspace functionality.Signed-off-by Yurii Monakov <[email protected]>--- common/cli_getch.c | 2 ++ 1 file changed, 2 insertions(+)common/cli_getch.c +2
-1@@ -46,6 +46,8 @@ static int cli_ch_esc(struct cli_ch_state *cch, int ichar,case 1 :if (ichar =='[' || ichar =='O' ) act =ESC_SAVE ; +else + act =ESC_CONVERTED ;break ;case 2 :switch (ichar) { --
Quoted 2 lines
2.34.1
This is a bit unfortunate. Basically the problem (as I understand it) is that characters are built up for processing so the expected ichar == 0 is never passed in.
I think the fix is reasonable. Does it work as well if use:
else if (ichar == '\e')
act = ESC_CONVERTED;?
Also please can you add a test case o test/common/cread.c
https://u-boot.readthedocs.io/en/latest/develop/tests_sandbox.html
Regards,
Simon