Scissors/patches/server/0014-Prevent-attributes-with-invalid-namespaces-from-bein.patch
allinkdev 871cc5653c
Clean up patches (#103)
* Clean up command block event patch

* Merge resource location patches

* Merge map decoration patches

* Merge Video's resource location patches

* Merge large tag reset patches
2023-06-16 22:54:59 -05:00

29 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
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 5da793c0754a943b12ef01cac1072b71afd27b0e..aed46e2ca3191e1c7dccb4eb7d71bd3be97c2993 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -46,6 +46,7 @@ import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.commons.lang3.EnumUtils;
@@ -484,7 +485,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;
}