From 0a8fbf91149b24a461305a88d1a72d5e797bffb6 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 3 Jan 2023 13:52:07 -0500 Subject: [PATCH] Validate model JSON paths before preloading them Fixes #1 --- .../embeddedt/modernfix/mixin/ModelBakeryMixin.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/embeddedt/modernfix/mixin/ModelBakeryMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/ModelBakeryMixin.java index 6ba3d382..0d557314 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/ModelBakeryMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/ModelBakeryMixin.java @@ -78,7 +78,15 @@ public abstract class ModelBakeryMixin { ModernFix.LOGGER.warn("Preloading JSONs in parallel..."); Stopwatch stopwatch = Stopwatch.createStarted(); useModelCache = false; - deserializedModelCache = Minecraft.getInstance().getResourceManager().getAllResourceLocations("models", p -> p.endsWith(".json")) + deserializedModelCache = Minecraft.getInstance().getResourceManager().getAllResourceLocations("models", p -> { + if(!p.endsWith(".json")) + return false; + for(int i = 0; i < p.length(); i++) { + if(!ResourceLocation.validatePathChar(p.charAt(i))) + return false; + } + return true; + }) .parallelStream() .map(location -> new ResourceLocation(location.getNamespace(), location.getPath().substring(7, location.getPath().length() - 5))) .map(location -> Pair.of(location, this.loadModelSafely(location)))