escape: make 'bad' parameter optional

Treat a NULL bad parameter just like an empty one: do not escape any
additional characters except for the CC chars.
This commit is contained in:
Lennart Poettering
2025-01-17 19:47:43 +00:00
committed by Luca Boccassi
parent 9cd064aa9f
commit ea844c49c3
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ TEST(cescape) {
TEST(xescape) {
_cleanup_free_ char *t = NULL;
assert_se(t = xescape("abc\\\"\b\f\n\r\t\v\a\003\177\234\313", ""));
assert_se(t = xescape("abc\\\"\b\f\n\r\t\v\a\003\177\234\313", /* bad= */ NULL));
ASSERT_STREQ(t, "abc\\x5c\"\\x08\\x0c\\x0a\\x0d\\x09\\x0b\\x07\\x03\\x7f\\x9c\\xcb");
}