From 6950f39d8cafc168d182074019919b91d3742338 Mon Sep 17 00:00:00 2001 From: Video Date: Wed, 30 Mar 2022 18:24:02 -0600 Subject: [PATCH] Prevent attributes with invalid namespaces from being applied to CraftMetaItems --- ...es-with-invalid-namespaces-from-bein.patch | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 patches/server/0022-Prevent-attributes-with-invalid-namespaces-from-bein.patch diff --git a/patches/server/0022-Prevent-attributes-with-invalid-namespaces-from-bein.patch b/patches/server/0022-Prevent-attributes-with-invalid-namespaces-from-bein.patch new file mode 100644 index 0000000..0ba7328 --- /dev/null +++ b/patches/server/0022-Prevent-attributes-with-invalid-namespaces-from-bein.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Video +Date: Wed, 30 Mar 2022 18:20:09 -0600 +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 +index 2e3220cbbea5f6cb9acb7f8fbaf2ff8f91b09234..8018709dfce483a9000ada93cf47812fd49458a8 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +@@ -45,6 +45,7 @@ import net.minecraft.nbt.NbtIo; + import net.minecraft.nbt.StringTag; + import net.minecraft.nbt.Tag; + import net.minecraft.network.chat.TextComponent; ++import net.minecraft.resources.ResourceLocation; // Scissors + import net.minecraft.world.item.BlockItem; + import org.apache.commons.codec.binary.Base64; + import org.apache.commons.lang.Validate; +@@ -481,7 +482,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier); + + String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(ATTRIBUTES_IDENTIFIER.NBT)); // Paper +- if (attributeName == null || attributeName.isEmpty()) { ++ if (attributeName == null || attributeName.isEmpty() || attributeName.length() < 256 || !ResourceLocation.isValidResourceLocation(attributeName)) { // Scissors + continue; + } +