diff --git a/src/windows-emulator-test/file_system_test.cpp b/src/windows-emulator-test/file_system_test.cpp new file mode 100644 index 00000000..8487395f --- /dev/null +++ b/src/windows-emulator-test/file_system_test.cpp @@ -0,0 +1,17 @@ +#include + +#include + +namespace test +{ + TEST(FileSystemTest, PathTraversalIsNotPossible) + { + const auto current_dir = std::filesystem::current_path(); + + const file_system fs{current_dir}; + + EXPECT_EQ(current_dir / "a", fs.translate(windows_path('a', {u"..", u"..", u"..", u"..", u"a.txt"}))); + EXPECT_EQ(current_dir / "a", fs.translate(windows_path('a', {u"b", u"..", u"..", u"b", u"..", u"a.txt"}))); + EXPECT_EQ(current_dir / "a", fs.translate(windows_path('a', {u"..", u"b"}))); + } +}