diff --git a/core/src/main/java/org/jahia/services/importexport/ImportExportBaseService.java b/core/src/main/java/org/jahia/services/importexport/ImportExportBaseService.java old mode 100755 new mode 100644 index b78829feff1..ac62fb7069c --- a/core/src/main/java/org/jahia/services/importexport/ImportExportBaseService.java +++ b/core/src/main/java/org/jahia/services/importexport/ImportExportBaseService.java @@ -232,7 +232,7 @@ public static String updatedServerDirectoryPath(String serverDirectoryPath) thro return null; } File exportPath = new File(serverDirectoryPath); - return exportPath.getCanonicalPath().startsWith(SettingsBean.getInstance().getJahiaExportsDiskPath()) + return exportPath.getCanonicalFile().toPath().startsWith(SettingsBean.getInstance().getJahiaExportsDiskPath()) ? exportPath.getCanonicalPath() : new File(SettingsBean.getInstance().getJahiaExportsDiskPath(), serverDirectoryPath).getCanonicalPath(); } @@ -266,7 +266,7 @@ public static boolean isDirectoryEmpty(String pathStr) throws IOException { public static boolean isValidServerDirectory(String serverDirectory) { try { File serverDirectoryFile = new File(serverDirectory); - if (!serverDirectoryFile.getCanonicalPath().startsWith(EXPORT_PATH.getCanonicalPath())) { + if (!serverDirectoryFile.getCanonicalFile().toPath().startsWith(EXPORT_PATH.getCanonicalFile().toPath())) { logger.error("User is trying to export to {} which is outside the allowed location {}", serverDirectory, EXPORT_PATH.getCanonicalPath()); return false; @@ -2023,7 +2023,7 @@ private String validateZipName(String filename) throws java.io.IOException { String canonicalPath = new File(filename).getCanonicalPath(); String canonicalID = new File(".").getCanonicalPath(); - if (canonicalPath.startsWith(canonicalID)) { + if (new File(filename).getCanonicalFile().toPath().startsWith(canonicalID)) { return canonicalPath.substring(canonicalID.length() + 1); } else { throw new IllegalStateException("File is outside extraction target directory.");