From bf07548695a05796f56a4118792af34561d3e103 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 17 Jul 2024 20:41:28 +0100 Subject: [PATCH] fix: add some file-extension bounds to schematic loading --- .../clipboard/io/BuiltInClipboardFormat.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java index 8a57411d6..736167056 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java @@ -112,6 +112,15 @@ public enum BuiltInClipboardFormat implements ClipboardFormat { return false; } + @Override + public boolean isFormat(File file) { + String name = file.getName().toLowerCase(Locale.ROOT); + if (name.endsWith(".schematic") || name.endsWith(".mcedit") || name.endsWith(".mce")) { + return false; + } + return super.isFormat(file); + } + @Override public String getPrimaryFileExtension() { return "schem"; @@ -151,6 +160,15 @@ public enum BuiltInClipboardFormat implements ClipboardFormat { return detectOldSpongeSchematic(inputStream, FastSchematicWriterV2.CURRENT_VERSION); } + @Override + public boolean isFormat(File file) { + String name = file.getName().toLowerCase(Locale.ROOT); + if (name.endsWith(".schematic") || name.endsWith(".mcedit") || name.endsWith(".mce")) { + return false; + } + return super.isFormat(file); + } + }, //FAWE end @@ -177,6 +195,15 @@ public enum BuiltInClipboardFormat implements ClipboardFormat { //FAWE end } + @Override + public boolean isFormat(File file) { + String name = file.getName().toLowerCase(Locale.ROOT); + if (!name.endsWith(".schematic") && !name.endsWith(".mcedit") && !name.endsWith(".mce")) { + return false; + } + return super.isFormat(file); + } + @Override public boolean isFormat(InputStream inputStream) { LinRootEntry rootEntry;