From 98da518b01b1e3d68c067bec378ed38c70f1a9ac Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Sat, 13 May 2023 11:41:32 -0500 Subject: [PATCH] Fix package whitelist system --- .../net/raphimc/viaproxy/injection/Java17ToJava8.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/raphimc/viaproxy/injection/Java17ToJava8.java b/src/main/java/net/raphimc/viaproxy/injection/Java17ToJava8.java index 2ad6f9e..1413774 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/Java17ToJava8.java +++ b/src/main/java/net/raphimc/viaproxy/injection/Java17ToJava8.java @@ -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);