Echi bad color (#15986)

* Outputting error on ecHi bad color
* Added a testcase
This commit is contained in:
bannsec 2020-02-16 22:54:48 -05:00 committed by GitHub
parent 78e21373be
commit 7a39bb9245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -465,6 +465,11 @@ static int cmd_eval(void *data, const char *input) {
char *dup = r_str_newf ("bgonly %s", argv[0]);
color_code = r_cons_pal_parse (dup, NULL);
R_FREE (dup);
if (!color_code) {
eprintf ("Unknown color %s\n", argv[0]);
r_str_argv_free (argv);
return true;
}
}
break;
case 'w': // "ecHw"
@ -477,14 +482,13 @@ static int cmd_eval(void *data, const char *input) {
if (argc > 1) {
char *dup = r_str_newf ("bgonly %s", argv[1]);
color_code = r_cons_pal_parse (dup, NULL);
R_FREE (dup);
if (!color_code) {
eprintf ("Unknown color %s\n", argv[1]);
r_str_argv_free (argv);
free (dup);
free (word);
return true;
}
R_FREE (dup);
}
break;
default:

View File

@ -278,3 +278,13 @@ ec comment rgb:001296 . italic
ec fname rgb:8d0004 . bold italic
EOF
RUN
NAME=ecHi
FILE=-
CMDS=<<EOF
ecHi xxxx
EOF
EXPECT_ERR=<<EOF
Unknown color xxxx
EOF
RUN