SPIGOT-2520: Better skull validation

This commit is contained in:
md_5 2016-07-13 11:47:57 +10:00
parent ca1bb1c445
commit 301db84d3d

View File

@ -1,10 +1,23 @@
--- a/net/minecraft/server/ItemSkull.java
+++ b/net/minecraft/server/ItemSkull.java
@@ -117,6 +117,7 @@
@@ -117,6 +117,20 @@
nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile));
return true;
} else {
+ nbttagcompound.remove("SkullOwner"); // CraftBukkit - remove broken skulls
+ // CraftBukkit start
+ boolean valid = true;
+
+ NBTTagList textures = nbttagcompound.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts
+ for (int i = 0; i < textures.size(); i++) {
+ if (textures.get(i) instanceof NBTTagCompound && !((NBTTagCompound) textures.get(i)).hasKeyOfType("Signature", 8)) {
+ valid = false;
+ }
+ }
+
+ if (!valid) {
+ nbttagcompound.remove("SkullOwner");
+ }
+ // CraftBukkit end
return false;
}
}