From: Karel Zak Date: Tue, 15 Jul 2025 13:35:05 +0000 (+0200) Subject: lib/color-names: Fix color name canonicalization X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=44ebe68c24da0bcf5aa1f48017d47d2d8995b0ed;p=thirdparty%2Futil-linux.git lib/color-names: Fix color name canonicalization Return NULL rather than a random string if it cannot be translated to the color sequence. Signed-off-by: Karel Zak --- diff --git a/lib/color-names.c b/lib/color-names.c index ec53e3d47..f7b194609 100644 --- a/lib/color-names.c +++ b/lib/color-names.c @@ -93,11 +93,14 @@ static int __color_canonicalize(const char *str, char **seq) *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" */