diff --git a/.locker/pom.xml b/.locker/pom.xml index f368f42..4b546b0 100644 --- a/.locker/pom.xml +++ b/.locker/pom.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 io.mvnpm - 3.0.22-SNAPSHOT + 3.0.23-SNAPSHOT mvnpm-locker pom diff --git a/pom.xml b/pom.xml index ad3ddd8..14cbd01 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 io.mvnpm mvnpm - 3.0.22-SNAPSHOT + 3.0.23-SNAPSHOT mvnpm Maven on NPM https://mvnpm.org/ diff --git a/src/main/java/io/mvnpm/file/type/JarClient.java b/src/main/java/io/mvnpm/file/type/JarClient.java index 2283f52..cd5bd6d 100644 --- a/src/main/java/io/mvnpm/file/type/JarClient.java +++ b/src/main/java/io/mvnpm/file/type/JarClient.java @@ -135,19 +135,18 @@ private void tgzEntryToJarEntry(io.mvnpm.npm.model.Package p, ArchiveEntry entry String name = entry.getName(); final boolean shouldAdd = !matches(FILES_TO_EXCLUDE, name); final boolean shouldTgz = matches(FILES_TO_TGZ, name); - - // do not add entries that will result in invalid zip file systems that will not be able to be opened - // by quarkus because it uses the ZipFileSystem implementation. - final String jarEntryPath = MVN_ROOT + importMapRoot + name; - final String tarEntryPath = importMapRoot + name; - // paths that include "/./" or "/../" as path element are invalid - if (jarEntryPath.startsWith("./") || jarEntryPath.contains("/./") - || (shouldTgz && (tarEntryPath.startsWith(".") || tarEntryPath.contains("/./")))) { - return; - } - if (shouldAdd || shouldTgz) { name = name.replaceFirst(NPM_ROOT, Constants.EMPTY); + // do not add entries that will result in invalid zip file systems that will not be able to be opened + // by quarkus because it uses the ZipFileSystem implementation. + final String jarEntryPath = MVN_ROOT + importMapRoot + name; + final String tarEntryPath = importMapRoot + name; + // paths that include "/./" or "/../" as path element are invalid + if (jarEntryPath.startsWith("./") || jarEntryPath.contains("/./") + || (shouldTgz && (tarEntryPath.startsWith(".") || tarEntryPath.contains("/./")))) { + return; + } + try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(baos, bufferSize)) { IOUtils.copy(tar, bos, bufferSize);