diff --git a/pom.xml b/pom.xml index 14f7619d5..f8095112a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ me.coley recaf https://github.com/Col-E/Recaf/ - 2.19.2 + 2.19.3 Recaf A modern java bytecode editor diff --git a/src/main/java/me/coley/recaf/Recaf.java b/src/main/java/me/coley/recaf/Recaf.java index 3c1a0ff3a..701649df4 100644 --- a/src/main/java/me/coley/recaf/Recaf.java +++ b/src/main/java/me/coley/recaf/Recaf.java @@ -31,7 +31,7 @@ * @author Matt */ public class Recaf { - public static final String VERSION = "2.19.2"; + public static final String VERSION = "2.19.3"; public static final String DOC_URL = "https://col-e.github.io/Recaf-documentation/"; public static final int ASM_VERSION = Opcodes.ASM9; private static Controller currentController; diff --git a/src/main/java/me/coley/recaf/workspace/EntryLoader.java b/src/main/java/me/coley/recaf/workspace/EntryLoader.java index 295a35920..b7ce362f3 100644 --- a/src/main/java/me/coley/recaf/workspace/EntryLoader.java +++ b/src/main/java/me/coley/recaf/workspace/EntryLoader.java @@ -1,5 +1,7 @@ package me.coley.recaf.workspace; +import me.coley.cafedude.InvalidClassException; +import me.coley.cafedude.io.ClassFileReader; import me.coley.recaf.plugin.PluginsManager; import me.coley.recaf.plugin.api.LoadInterceptorPlugin; import me.coley.recaf.util.ClassUtil; @@ -24,6 +26,7 @@ public class EntryLoader { private final Map classes = new HashMap<>(); private final Map files = new HashMap<>(); private final Map invalidClasses = new HashMap<>(); + private final Map invalidJunkClasses = new HashMap<>(); /** * @return New archive entry loader instance. @@ -52,14 +55,32 @@ public static EntryLoader create() { public boolean onClass(String entryName, byte[] value) { // Check if class is valid. If it is not it will be stored for later. if (!ClassUtil.isValidClass(value)) { - if (invalidClasses.containsKey(entryName)) { - debug("Skipping duplicate invalid class '{}'", entryName); + try { + // If the data can be read, overwrite whatever entry we have previously seen + new ClassFileReader().read(value); + invalidClasses.put(entryName, value); + if (invalidJunkClasses.remove(entryName) != null) { + debug("Replacing class '{}' previously associated with non-class junk with" + + " newly discovered class data", entryName); + } + return false; + } catch (InvalidClassException e) { + // Skip if we think this is junk data that is masking an invalid class we already recovered + if (invalidClasses.containsKey(entryName)) { + debug("Skipping masking junk data for class '{}'", entryName); + return false; + } + // Doesnt look like the CAFEDOOD backup parser can read it either. + if (invalidJunkClasses.containsKey(entryName)) { + // Already seen it. Probably dupe junk data. + debug("Skipping duplicate invalid class '{}'", entryName); + return false; + } else { + debug("Invalid class detected, not parsable by backup reader \"{}\"", entryName); + } + invalidJunkClasses.put(entryName, value); return false; - } else { - debug("Invalid class detected \"{}\"", entryName); } - invalidClasses.put(entryName, value); - return false; } // Check if we've already seen this class String clsName = new ClassReader(value).getClassName();