Skip to content

Commit

Permalink
Fix jar structure
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <[email protected]>
  • Loading branch information
phillip-kruger committed Feb 16, 2024
1 parent 0715e75 commit 79e8c07
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .locker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.mvnpm</groupId>
<version>3.0.22-SNAPSHOT</version>
<version>3.0.23-SNAPSHOT</version>
<artifactId>mvnpm-locker</artifactId>
<packaging>pom</packaging>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.mvnpm</groupId>
<artifactId>mvnpm</artifactId>
<version>3.0.22-SNAPSHOT</version>
<version>3.0.23-SNAPSHOT</version>
<name>mvnpm</name>
<description>Maven on NPM</description>
<url>https://mvnpm.org/</url>
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/io/mvnpm/file/type/JarClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 79e8c07

Please sign in to comment.