Paper/patches/server/0110-Filter-bad-data-from-ArmorStand-and-SpawnEgg-items.patch
Nassim Jahnke 17f71ac87b
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5904)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
70d24eb8 SPIGOT-6587: Update documentation/error of drop chance API

CraftBukkit Changes:
470050ad SPIGOT-6587: Update documentation/error of drop chance API
1c39efa3 Fix Inventory#getViewers on the player inventory not returning the player first time their inventory is opened
d161627d Fix PrepareItemCraftEvent#isRepair
aa1fae73 SPIGOT-6586: EntityChangeBlockEvent for falling block does not cancel properly
8a04072e SPIGOT-6583: Throwing eggs doesn't make sounds

Spigot Changes:
f773da84 Remove redundant patch
cd367234 Rebuild patches
2021-06-20 21:25:59 +02:00

47 lines
2.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
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 96247356d7888d5681bff60567add1188aedb18b..e83216be5a00d5b927d8c2fc364551bd3077c974 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -306,4 +306,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/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 1d538f490c7aa48991446fb55c7f0916bb5d5e29..69f385c57f3716a489781debb32b4adf1cb9383d 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -309,6 +309,18 @@ public class FallingBlockEntity extends Entity {
@Override
protected void readAdditionalSaveData(CompoundTag nbt) {
this.blockState = NbtUtils.readBlockState(nbt.getCompound("BlockState"));
+ // Paper start - Block FallingBlocks with Command Blocks
+ final Block b = this.blockState.getBlock();
+ if (this.level.paperConfig.filterNBTFromSpawnEgg
+ && (b == Blocks.COMMAND_BLOCK
+ || b == Blocks.REPEATING_COMMAND_BLOCK
+ || b == Blocks.CHAIN_COMMAND_BLOCK
+ || b == Blocks.JIGSAW
+ || b == Blocks.STRUCTURE_BLOCK
+ || b instanceof net.minecraft.world.level.block.GameMasterBlock)) {
+ this.blockState = Blocks.STONE.defaultBlockState();
+ }
+ // Paper end
this.time = nbt.getInt("Time");
if (nbt.contains("HurtEntities", 99)) {
this.hurtEntities = nbt.getBoolean("HurtEntities");