Skip to content

Commit 977b4e9

Browse files
committed
Windows-compatible Path relativizing
1 parent 257b2eb commit 977b4e9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/org/commonwl/view/workflow/WorkflowService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.io.IOException;
4444
import java.nio.file.Files;
4545
import java.nio.file.Path;
46+
import java.nio.file.Paths;
4647
import java.util.ArrayList;
4748
import java.util.Calendar;
4849
import java.util.Date;
@@ -213,7 +214,8 @@ public List<WorkflowOverview> getWorkflowsFromDirectory(GitDetails gitInfo) thro
213214

214215
Path localPath = repo.getRepository().getWorkTree().toPath();
215216
Path pathToDirectory = localPath.resolve(gitInfo.getPath()).normalize().toAbsolutePath();
216-
if (pathToDirectory.toString().equals("/")) {
217+
Path root = Paths.get("/").toAbsolutePath();
218+
if (pathToDirectory.equals(root)) {
217219
pathToDirectory = localPath;
218220
} else if (!pathToDirectory.startsWith(localPath.normalize().toAbsolutePath())) {
219221
// Prevent path traversal attacks

0 commit comments

Comments
 (0)