1
0
mirror of https://github.com/CPunch/Laika.git synced 2024-12-26 04:40:05 +00:00

shellT_addChar(): Added ascii validation, ignore non-printable input

This commit is contained in:
CPunch 2022-04-15 15:40:25 -05:00
parent 9a6562f440
commit d94a6a5e17

View File

@ -153,6 +153,10 @@ void shellT_setPrompt(char *_prompt) {
prompt = _prompt;
}
bool isAscii(int c) {
return c >= ' ' && c <= '~'; /* covers every non-controller related ascii characters (ignoring the extended character range) */
}
void shellT_addChar(tShell_client *client, int c) {
int i;
@ -189,6 +193,10 @@ void shellT_addChar(tShell_client *client, int c) {
break;
case KEY_UP: case KEY_DOWN: break; /* ignore these */
default:
/* we only want to accept valid input, just ignore non-ascii characters */
if (!isAscii(c))
return;
laikaM_growarray(char, cmd, 1, cmdCount, cmdCap);
laikaM_insertarray(cmd, cmdCount, cmdCursor, 1);
cmd[cmdCursor++] = c;