From bd503d35b044c311e77a92e86668d14f5d3db39f Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sun, 13 Nov 2016 19:36:23 -0600 Subject: Expand NBT filtering from last commit cc GH-478 --- ...d-data-from-ArmorStand-and-SpawnEgg-items.patch | 51 ++++++++++++++++++---- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/Spigot-Server-Patches/0182-Filter-bad-data-from-ArmorStand-and-SpawnEgg-items.patch b/Spigot-Server-Patches/0182-Filter-bad-data-from-ArmorStand-and-SpawnEgg-items.patch index 6571b2198e..de83f293ad 100644 --- a/Spigot-Server-Patches/0182-Filter-bad-data-from-ArmorStand-and-SpawnEgg-items.patch +++ b/Spigot-Server-Patches/0182-Filter-bad-data-from-ArmorStand-and-SpawnEgg-items.patch @@ -1,28 +1,63 @@ -From e7490178a70a45f8e3a641ae338d65c4a04620eb Mon Sep 17 00:00:00 2001 +From 27f801bd116e4387e6b7b1696b23adf140940e4a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sat, 12 Nov 2016 23:25:22 -0600 Subject: [PATCH] Filter bad data from ArmorStand and SpawnEgg items +diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +index 9d361cb..651f23e 100644 +--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java ++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +@@ -403,4 +403,12 @@ public class PaperWorldConfig { + private void removeCorruptTEs() { + removeCorruptTEs = getBoolean("remove-corrupt-tile-entities", false); + } ++ ++ public boolean filterNBTFromSpawnEgg = true; ++ private void fitlerNBTFromSpawnEgg() { ++ filterNBTFromSpawnEgg = getBoolean("filter-nbt-data-from-spawn-eggs-and-related", true); ++ if (!filterNBTFromSpawnEgg) { ++ Bukkit.getLogger().warning("Spawn Egg and Armor Stand NBT filtering disabled, this is a potential security risk"); ++ } ++ } + } +diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java +index dcfdd31..f62fdde 100644 +--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java ++++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java +@@ -250,6 +250,12 @@ public class EntityFallingBlock extends Entity { + this.block = Block.getById(nbttagcompound.getByte("Tile") & 255).fromLegacyData(i); + } + ++ // Paper start - Block FallingBlocks with Command Blocks ++ if (this.world.paperConfig.filterNBTFromSpawnEgg && this.block.getBlock() == Blocks.COMMAND_BLOCK) { ++ this.block = Blocks.STONE.getBlockData(); ++ } ++ // Paper end ++ + this.ticksLived = nbttagcompound.getInt("Time"); + Block block = this.block.getBlock(); + diff --git a/src/main/java/net/minecraft/server/ItemMonsterEgg.java b/src/main/java/net/minecraft/server/ItemMonsterEgg.java -index 6317cba..06149e8 100644 +index 6317cba..1b3816f 100644 --- a/src/main/java/net/minecraft/server/ItemMonsterEgg.java +++ b/src/main/java/net/minecraft/server/ItemMonsterEgg.java -@@ -82,8 +82,12 @@ public class ItemMonsterEgg extends Item { - +@@ -83,7 +83,14 @@ public class ItemMonsterEgg extends Item { NBTTagCompound nbttagcompound1 = entity.e(new NBTTagCompound()); UUID uuid = entity.getUniqueID(); -- + - nbttagcompound1.a(nbttagcompound.getCompound("EntityTag")); + // Paper start - Filter out position and motion information + final NBTTagCompound entityTag = nbttagcompound.getCompound("EntityTag"); -+ entityTag.remove("Pos"); -+ entityTag.remove("Motion"); ++ if (world.paperConfig.filterNBTFromSpawnEgg) { ++ entityTag.remove("Pos"); ++ entityTag.remove("Motion"); ++ } + nbttagcompound1.a(entityTag); + // Paper end entity.a(uuid); entity.f(nbttagcompound1); } -- -2.10.2.windows.1 +2.10.2 -- cgit v1.2.3