You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2022/10/10 12:02:57 UTC
[sling-org-apache-sling-feature-cpconverter] branch master updated: SLING-11615 : Handling of initial content might fail on Windows
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git
The following commit(s) were added to refs/heads/master by this push:
new f8e82bc SLING-11615 : Handling of initial content might fail on Windows
f8e82bc is described below
commit f8e82bc5c479adeff88e724f560af0d55efa6000
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Oct 10 14:02:51 2022 +0200
SLING-11615 : Handling of initial content might fail on Windows
---
.../SlingInitialContentBundleEntryMetaDataCollector.java | 10 ++++------
.../feature/cpconverter/vltpkg/VaultPackageAssembler.java | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/handlers/slinginitialcontent/SlingInitialContentBundleEntryMetaDataCollector.java b/src/main/java/org/apache/sling/feature/cpconverter/handlers/slinginitialcontent/SlingInitialContentBundleEntryMetaDataCollector.java
index dfe834f..65dbbdd 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/handlers/slinginitialcontent/SlingInitialContentBundleEntryMetaDataCollector.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/handlers/slinginitialcontent/SlingInitialContentBundleEntryMetaDataCollector.java
@@ -43,8 +43,6 @@ import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
-import static org.apache.sling.feature.cpconverter.shared.ConverterConstants.SLASH;
-
/**
* Handles collecting the metadata for each sling initial content entry, to be used for extraction in another loop
*/
@@ -120,12 +118,12 @@ class SlingInitialContentBundleEntryMetaDataCollector {
try (InputStream input = new BufferedInputStream(jarFile.getInputStream(jarEntry))) {
if (jarEntryIsSlingInitialContent(context, jarEntry)) {
- File targetFile = new File(contentPackage2FeatureModelConverter.getTempDirectory(), jarEntry.getName());
+ File targetFile = new File(contentPackage2FeatureModelConverter.getTempDirectory(), jarEntry.getName().replace('/', File.separatorChar));
String canonicalDestinationPath = targetFile.getCanonicalPath();
if (!checkIfPathStartsWithOrIsEqual(contentPackage2FeatureModelConverter.getTempDirectory().getCanonicalPath(), canonicalDestinationPath)) {
- throw new IOException("Entry is outside of the target directory");
+ throw new IOException("Entry is outside of the target directory " + canonicalDestinationPath);
}
targetFile.getParentFile().mkdirs();
@@ -196,8 +194,8 @@ class SlingInitialContentBundleEntryMetaDataCollector {
private static boolean checkIfPathStartsWithOrIsEqual(String pathA, String pathB) {
String fixedPath = pathA;
- if (!fixedPath.endsWith(SLASH)) {
- fixedPath = pathA + SLASH;
+ if (!fixedPath.endsWith(File.separator)) {
+ fixedPath = pathA + File.separatorChar;
}
return pathB.startsWith(fixedPath) || pathB.equals(pathA);
}
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/vltpkg/VaultPackageAssembler.java b/src/main/java/org/apache/sling/feature/cpconverter/vltpkg/VaultPackageAssembler.java
index 817a882..347014b 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/vltpkg/VaultPackageAssembler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/vltpkg/VaultPackageAssembler.java
@@ -252,7 +252,7 @@ public class VaultPackageAssembler {
}
- return new File(storingDirectory, path);
+ return new File(storingDirectory, path.replace(SLASH, File.separator));
}
/**