summaryrefslogtreecommitdiff
path: root/src/test/test-path-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-10-02 10:51:19 +0200
committerSven Eden <yamakuzure@gmx.net>2017-11-22 08:25:34 +0100
commit0b49a6ad440392bc8758db5dfd522287c80ee6a8 (patch)
treee284ba11db4889f967af0ed8fb5d0feb576a3717 /src/test/test-path-util.c
parent39a1b2e5627f6434881978e7521860499c3ab8a0 (diff)
path-util: some updates to path_make_relative()
Don't miscount number of "../" to generate, if we "." is included in an input path. Also, refuse if we encounter "../" since we can't possibly follow that up properly, without file system access. Some other modernizations.
Diffstat (limited to 'src/test/test-path-util.c')
-rw-r--r--src/test/test-path-util.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index 08d12d95b..5bfafce2d 100644
--- a/src/test/test-path-util.c
+++ b/src/test/test-path-util.c
@@ -262,6 +262,7 @@ static void test_make_relative(void) {
assert_se(path_make_relative("some/relative/path", "/some/path", &result) < 0);
assert_se(path_make_relative("/some/path", "some/relative/path", &result) < 0);
+ assert_se(path_make_relative("/some/dotdot/../path", "/some/path", &result) < 0);
#define test(from_dir, to_path, expected) { \
_cleanup_free_ char *z = NULL; \
@@ -275,6 +276,7 @@ static void test_make_relative(void) {
test("/some/path", "/some/path/in/subdir", "in/subdir");
test("/some/path", "/", "../..");
test("/some/path", "/some/other/path", "../other/path");
+ test("/some/path/./dot", "/some/further/path", "../../further/path");
test("//extra/////slashes///won't////fool///anybody//", "////extra///slashes////are/just///fine///", "../../../are/just/fine");
}
#endif // 0