Return NULL rather than a random string if it cannot be translated to
the color sequence.
Signed-off-by: Karel Zak <kzak@redhat.com>
*seq = NULL;
/* convert color names like "red" to the real sequence */
- if (*str != '\\' && isalpha(*str)) {
+ if (*str != '\\' && !strchr(str, ';') && isalpha(*str)) {
const char *s = color_sequence_from_colorname(str);
- *seq = strdup(s ? s : str);
- return *seq ? 0 : -ENOMEM;
+ if (s) {
+ *seq = strdup(s);
+ return *seq ? 0 : -ENOMEM;
+ }
+ return 1;
}
/* convert xx;yy sequences to "\033[xx;yy" */