From 0b924c5c23a89760ddecf8d8f6baa19333f9b667 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 30 May 2023 17:57:21 +0200 Subject: filesystem: Add logic for handling (non-upwards) symlinks --- test/utils/cpp/path.test.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/utils/cpp/path.test.cpp') diff --git a/test/utils/cpp/path.test.cpp b/test/utils/cpp/path.test.cpp index d6d4eb85..5a450fd5 100644 --- a/test/utils/cpp/path.test.cpp +++ b/test/utils/cpp/path.test.cpp @@ -32,3 +32,11 @@ TEST_CASE("normalization", "[path]") { CHECK(ToNormalPath(std::filesystem::path{"foo/.."}).string() == "."); CHECK(ToNormalPath(std::filesystem::path{"./foo/.."}).string() == "."); } + +TEST_CASE("non-upwards condition", "[path]") { + CHECK_FALSE(PathIsNonUpwards("/foo")); // absolute path + CHECK(PathIsNonUpwards("foo")); // relative non-upwards + CHECK_FALSE(PathIsNonUpwards("../foo")); // relative not non-upwards + CHECK_FALSE(PathIsNonUpwards( + "foo/../bar/../../foo")); // relative with non-upwards indirection +} -- cgit v1.2.3