Scissors/patches/server/0010-Prevent-attributes-with-invalid-namespaces-from-bein.patch

29 lines
1.5 KiB
Diff
Raw Normal View History

2024-05-08 17:47:03 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Wed, 8 May 2024 12:26:49 -0500
Subject: [PATCH] Prevent attributes with invalid namespaces from being applied
to CraftMetaItems
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
2024-05-08 18:13:08 +00:00
index 03f9fff7c06bf5f166d6277e3aa6adb5f646042d..1c48622db32bc99527bb551b5b71215b4eaf123c 100644
2024-05-08 17:47:03 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -50,6 +50,7 @@ import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Unit;
import net.minecraft.world.entity.EquipmentSlotGroup;
2024-05-08 18:13:08 +00:00
@@ -739,7 +740,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
2024-05-08 17:47:03 +00:00
continue;
}
String attributeName = (String) obj;
- if (Strings.isNullOrEmpty(attributeName)) {
+ if (Strings.isNullOrEmpty(attributeName) || attributeName.length() > 256 || !ResourceLocation.isValidResourceLocation(attributeName)) { // Scissors
continue;
}
List<?> list = SerializableMeta.getObject(List.class, mods, attributeName, true);