diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index 7c7226f50..03525672d 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -23,7 +23,6 @@ def setup_and_teardown(self): # Teardown stop_server() - @pytest.mark.skipif(platform.system() != "Linux", reason="Todo: fix later on Mac and Window") def test_api_create_file_successfully(self): # Define file path file_path_rel = os.path.join("e2e-test", "api", "files", "blank.txt") diff --git a/engine/repositories/file_fs_repository.cc b/engine/repositories/file_fs_repository.cc index f5b349f45..67c0981ba 100644 --- a/engine/repositories/file_fs_repository.cc +++ b/engine/repositories/file_fs_repository.cc @@ -18,14 +18,10 @@ std::filesystem::path SanitizePath(const std::filesystem::path& user_input, std::filesystem::path resolved_path = std::filesystem::weakly_canonical( std::filesystem::path(basedir) / std::filesystem::path(user_input)); /* Ensure the resolved path is within our basedir */ - for (auto p = resolved_path; !p.empty(); p = p.parent_path()) { - if (std::filesystem::equivalent(p, abs_base)) { - return resolved_path; - } - if (p == p.parent_path()) { // reached the root directory - break; - } + if (resolved_path.string().find(abs_base.string()) != std::string::npos) { + return resolved_path; } + return {}; }