diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index b43ea73b9b1..7033de68a1e 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -857,7 +857,7 @@ int mount_option_mangle( _cleanup_free_ char *word = NULL; const struct libmnt_optmap *ent; - r = extract_first_word(&p, &word, ",", EXTRACT_KEEP_QUOTE); + r = extract_first_word(&p, &word, ",", EXTRACT_KEEP_QUOTE | EXTRACT_RETAIN_ESCAPE); if (r < 0) return r; if (r == 0) diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c index ccaaacc812d..18ebed3e141 100644 --- a/src/test/test-mount-util.c +++ b/src/test/test-mount-util.c @@ -81,6 +81,11 @@ TEST(mount_option_mangle) { assert_se(f == 0); ASSERT_STREQ(opts, "mode=01777,size=10%,nr_inodes=400k,uid=496107520,gid=496107520,context=\"system_u:object_r:svirt_sandbox_file_t:s0:c0,c1\""); opts = mfree(opts); + + assert_se(mount_option_mangle("lower=/path/one/with/some\\:colons:/path/two", 0, &f, &opts) == 0); + assert_se(f == 0); + ASSERT_STREQ(opts, "lower=/path/one/with/some\\:colons:/path/two"); + opts = mfree(opts); } static void test_mount_flags_to_string_one(unsigned long flags, const char *expected) {