Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizzio-dotCMS committed Dec 19, 2024
1 parent 581df65 commit 491efa3
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,16 @@ public static List<String> parseRootPaths(final File workspace, final File sourc
var workspaceCount = workspacePath.getNameCount();
var sourceCount = sourcePath.getNameCount();

if (sourceCount < workspaceCount) {
if (!sourcePath.startsWith(workspacePath) ) {
throw new IllegalArgumentException("Source path cannot be outside of the workspace");
}

final Path filesPath = Path.of(workspace.getAbsolutePath(), FILES_NAMESPACE)
.toAbsolutePath().normalize();
// Check if we are inside the workspace but also inside the files folder
if (sourceCount > workspaceCount + 1 || (sourceCount == workspaceCount + 1 && !sourcePath.startsWith(filesPath))) {
if ((sourceCount > workspaceCount + 1 || sourceCount == workspaceCount + 1) && !sourcePath.startsWith(filesPath)) {
logger.warn("Invalid source path provided for a files push {}. Source path must be inside the files folder. otherwise it will fall back to workspace. {}", sourcePath, workspacePath);
System.out.println("Invalid source path provided for a files push. Source path must be inside the files folder. otherwise it will fall back to workspace." + sourcePath + " " + workspacePath);
//if a source path is provided, but it is not inside the files folder but still is a valid folder then we will fall back to the workspace
return parseRootPaths(workspacePath, workspaceCount, workspaceCount);
}
Expand Down

0 comments on commit 491efa3

Please sign in to comment.