QuiltMC / quilt-loader

The loader for Quilt mods.
Apache License 2.0
470 stars 86 forks source link

Fix knot class loading allowlist not working #430

Closed LostLuma closed 4 months ago

LostLuma commented 4 months ago

Resolves #251.

The method of looking up which prefixes were (dis)allowed was flawed as it always looked up using the entire path to a class file (including the part in the jar), whereas the allowlist only maps from the path to the jar to allowed prefixes in the jar.

I've also changed UrlUtil.asUrl to normalize the path as otherwise it produces URLs with a full stop at the current working directory, which caused issues with looking up the prefixes as well. See an equivalent example:

- Path.of("./src/hello.txt").toUri().toURL();
- $1 ==> file:/C:/Users/lilly/projects/quilt-loader/./src/hello.txt
+ Path.of("./src/hello.txt").toAbsolutePath().normalize().toUri().toURL();
+ $2 ==> file:/C:/Users/lilly/projects/quilt-loader/src/hello.txt