CB-1994 update rm errors

This commit is contained in:
Alexander Skoblikov
2022-05-24 14:47:21 +03:00
parent 64ab41b436
commit 9dc51140a5
@@ -36,6 +36,7 @@ import org.jkiss.utils.CommonUtils;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.time.OffsetDateTime;
@@ -266,11 +267,15 @@ public class LocalResourceController implements RMController {
throw new DBException("Error creating project path", e);
}
}
Path targetPath = projectPath.resolve(resourcePath).normalize();
if (!targetPath.startsWith(projectPath)) {
throw new DBException("Invalid resource path");
try {
Path targetPath = projectPath.resolve(resourcePath).normalize();
if (!targetPath.startsWith(projectPath)) {
throw new DBException("Invalid resource path");
}
return targetPath;
} catch (InvalidPathException e) {
throw new DBException("Resource path contains invalid characters");
}
return targetPath;
}
private RMProject makeProjectFromPath(Path path, String prefix, boolean checkExistence) {