From 20e98a9eb7ee0df59e9ce6192d57c76257ec9725 Mon Sep 17 00:00:00 2001
From: Mike Yuan <me@yhndnzj.com>
Date: Tue, 9 Apr 2024 21:54:30 +0800
Subject: [PATCH 0536/1160] shared/open-file: use xescape to escape ':'
Fixes #32179
(cherry picked from commit c1f9509f79b1edf53975ebfa2052a23b23c42a49)
src/shared/open-file.c | 2 +-
src/test/test-open-file.c | 10 ++++------
2 files changed, 5 insertions(+), 7 deletions(-)
@@ -96,7 +96,7 @@ int open_file_to_string(const OpenFile *of, char **ret) {
assert(of);
assert(ret);
- s = shell_escape(of->path, ":");
+ s = xescape(of->path, ":");
if (!s)
return -ENOMEM;
@@ -172,14 +172,12 @@ TEST(open_file_to_string) {
assert_se(streq(s, "/proc/1/ns/mnt::read-only"));
s = mfree(s);
- assert_se(free_and_strdup(&of->path, "/path:with:colon"));
- assert_se(free_and_strdup(&of->fdname, "path:with:colon"));
+ assert_se(free_and_strdup(&of->path, "/path:with:colon") >= 0);
+ assert_se(free_and_strdup(&of->fdname, "path:with:colon") >= 0);
of->flags = 0;
- r = open_file_to_string(of, &s);
-
- assert_se(r >= 0);
- assert_se(streq(s, "/path\\:with\\:colon"));
+ assert_se(open_file_to_string(of, &s) >= 0);
+ assert_se(streq(s, "/path\\x3awith\\x3acolon"));
}
DEFINE_TEST_MAIN(LOG_INFO);
--
2.33.0