rcfile: reject things like "M-Del" and "^{" as invalid key names

This fixes https://savannah.gnu.org/bugs/?54274.
master
Benno Schulenberg 2018-07-11 14:42:10 +02:00
parent acadf71b13
commit 3bac3c4c78
1 changed files with 2 additions and 2 deletions

View File

@ -448,14 +448,14 @@ int keycode_from_string(const char *keystring)
if (keystring[0] == '^') {
if (strcasecmp(keystring, "^Space") == 0)
return 0;
if (strlen(keystring) == 2)
if (keystring[1] <= '_' && strlen(keystring) == 2)
return keystring[1] - 64;
else
return -1;
} else if (keystring[0] == 'M') {
if (strcasecmp(keystring, "M-Space") == 0)
return (int)' ';
if (keystring[1] == '-')
if (keystring[1] == '-' && strlen(keystring) == 3)
return tolower((unsigned char)keystring[2]);
else
return -1;