]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
string-util: accept ":" when stripping ANSI color sequences 40366/head
authorLennart Poettering <lennart@poettering.net>
Fri, 16 Jan 2026 21:29:40 +0000 (22:29 +0100)
committerLennart Poettering <lennart@poettering.net>
Sat, 17 Jan 2026 11:07:36 +0000 (12:07 +0100)
Since 6eabe9f2ff48c1b6924724d5afe64e7b661ccdbf we generate sequences
with ":", hence we better also know how to strip them.

(Without this patch we'd strip simple ANSI colors, but not RGB ones that
use ":" syntax).

(While we are at it, also drop a duplicate "0" in the list of valid
chars)

src/basic/string-util.c

index 0c5c0a62872d59c71cdfa2a8b1d10a3bbb120f1a..ecd0277577d07eb25d041925624404ea93ced1bf 100644 (file)
@@ -735,7 +735,7 @@ char* strip_tab_ansi(char **ibuf, size_t *_isz, size_t highlight[2]) {
                 case STATE_CSI:
                         assert(n_carriage_returns == 0);
 
-                        if (eot || !strchr("01234567890;m", *i)) { /* EOT or invalid chars in sequence */
+                        if (eot || !strchr(DIGITS ";:m", *i)) { /* EOT or invalid chars in sequence */
                                 fputc('\x1B', f);
                                 fputc('[', f);
                                 advance_offsets(i - *ibuf, highlight, shift, 2);