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>
2024-06-14 23:02:52 +00:00
Date: Fri, 14 Jun 2024 18:00:35 -0500
2024-05-08 17:47:03 +00:00
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-06-14 23:02:52 +00:00
index b6cd6897844aa9c8b9a94e41c56c4cfe4ac78780..34130c2cc3f643fcfe32a02747c45dd1eba05396 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
2024-06-14 23:02:52 +00:00
@@ -57,6 +57,7 @@ import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.SnbtPrinterTagVisitor;
2024-05-08 17:47:03 +00:00
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-06-14 23:02:52 +00:00
@@ -764,7 +765,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);