Skip to content

Commit

Permalink
Add a fallback check for weird jar paths in dep deobfuscation
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenraven committed Apr 27, 2023
1 parent 5280738 commit 99b2b2e
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.OutputStream;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand All @@ -17,6 +18,7 @@
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.stream.Collectors;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -92,7 +94,18 @@ private static boolean mustRunDeobf(File inputFile, Set<File> filesToDeobf, Set<
if (!mustRunDeobf) {
final Path inputPath = inputFile.toPath();
final String moduleSpec = Utilities.getModuleSpecFromCachePath(inputPath);
mustRunDeobf = modulesToDeobf.contains(moduleSpec);
if (moduleSpec == null) {
for (final String foundSpec : modulesToDeobf) {
final List<String> parts = Arrays.stream(foundSpec.split(":")).filter(StringUtils::isNotBlank)
.collect(Collectors.toList());
final String foundJar = StringUtils.join(parts, "-") + ".jar";
if (inputPath.endsWith(foundJar)) {
mustRunDeobf = true;
}
}
} else {
mustRunDeobf = modulesToDeobf.contains(moduleSpec);
}
}

return mustRunDeobf;
Expand Down

0 comments on commit 99b2b2e

Please sign in to comment.