Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,17 @@ private Path getTargetPath(@NotNull String projectId, @NotNull String resourcePa
if (!targetPath.startsWith(projectPath)) {
throw new DBException("Invalid resource path");
}
if (ServletAppUtils.getServletApplication().isMultiNode()) {
// we need to check that the resource path starts with a valid resource type folder
Path relative = projectPath.relativize(targetPath);
if (relative.getNameCount() == 0) {
throw new DBException("Resource points to project root");
}
String firstSegment = relative.getName(0).toString();
if (ResourceTypeRegistry.getInstance().getResourceTypeByRootPath(null, firstSegment) == null) {
throw new DBException("Invalid resource type");
}
}
return targetPath;
} catch (InvalidPathException e) {
throw new DBException("Resource path contains invalid characters");
Expand Down