Fix package whitelist system

This commit is contained in:
Josiah (Gaming32) Glosson 2023-05-13 11:41:32 -05:00
parent 1e1b8be79b
commit 98da518b01

View file

@ -78,8 +78,15 @@ public class Java17ToJava8 implements IBytecodeTransformer {
@Override
public byte[] transform(String className, byte[] bytecode, boolean calculateStackMapFrames) {
for (String whitelistedPackage : this.whitelistedPackages) {
if (!className.startsWith(whitelistedPackage)) return null;
if (!whitelistedPackages.isEmpty()) {
int dotIndex = className.lastIndexOf('.');
if (dotIndex == -1 && !whitelistedPackages.contains("")) return null;
String pkg = className.substring(0, dotIndex);
while (!whitelistedPackages.contains(pkg)) {
dotIndex = pkg.lastIndexOf('.');
if (dotIndex == -1) return null;
pkg = pkg.substring(0, dotIndex);
}
}
final ClassNode classNode = ASMUtils.fromBytes(bytecode);