diff --git a/Spigot-Server-Patches/Fix-sign-edit-memory-leak.patch b/Spigot-Server-Patches/Fix-sign-edit-memory-leak.patch index 7fc81c4a7..070992945 100644 --- a/Spigot-Server-Patches/Fix-sign-edit-memory-leak.patch +++ b/Spigot-Server-Patches/Fix-sign-edit-memory-leak.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Fix sign edit memory leak when a player edits a sign, a reference to their Entity is never cleand up. diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 9b857a8d1..53ef6bf17 100644 +index 04344a3711..5c58b85388 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { @@ -19,13 +19,13 @@ index 9b857a8d1..53ef6bf17 100644 this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit return; diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java -index 05fb2eea5..ca80391d7 100644 +index c2bcbbbab9..fdb771317a 100644 --- a/src/main/java/net/minecraft/server/TileEntitySign.java +++ b/src/main/java/net/minecraft/server/TileEntitySign.java @@ -0,0 +0,0 @@ public class TileEntitySign extends TileEntity implements ICommandListener { + // Paper start - Strip invalid unicode from signs on load private static final boolean keepInvalidUnicode = Boolean.getBoolean("Paper.keepInvalidUnicode"); // Allow people to keep their bad unicode if they really want it private boolean privateUnicodeRemoved = false; - public static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); + public java.util.UUID signEditor; // Paper end diff --git a/Spigot-Server-Patches/Limit-Client-Sign-length-more.patch b/Spigot-Server-Patches/Limit-Client-Sign-length-more.patch new file mode 100644 index 000000000..88ede168e --- /dev/null +++ b/Spigot-Server-Patches/Limit-Client-Sign-length-more.patch @@ -0,0 +1,52 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 27 Feb 2019 22:18:40 -0500 +Subject: [PATCH] Limit Client Sign length more + +modified clients can send more data from the client +to the server and it would get stored on the sign as sent. + +Mojang has a limit of 384 which is much higher than reasonable. + +the client can barely render around 16 characters as-is, but formatting +codes can get it to be more than 16 actual length. + +Set a limit of 80 which should give an average of 16 characters 2 +sets of legacy formatting codes which should be plenty for all uses. + +This does not strip any existing data from the NBT as plugins +may use this for storing data out of the rendered area. + +it only impacts data sent from the client. + +Set -DPaper.maxSignLength=XX to change limit or -1 to disable + +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index 5c58b85388..dc8c20efb4 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { + private int E; + private int receivedMovePackets; + private int processedMovePackets; ++ private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); + private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit + + public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { + String[] lines = new String[4]; + + for (int i = 0; i < astring.length; ++i) { ++ // Paper start - cap line length - modified clients can send longer data than normal ++ if (MAX_SIGN_LINE_LENGTH > 0 && astring[i].length() > MAX_SIGN_LINE_LENGTH) { ++ // This handles multibyte characters as 1 ++ int offset = astring[i].codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum(); ++ if (offset > astring.length) { ++ astring[i] = astring[i].substring(0, offset); ++ } ++ } ++ // Paper end + lines[i] = SharedConstants.a(astring[i]); //Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. + } + SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/Strip-extra-Sign-data-to-from-client.patch b/Spigot-Server-Patches/Strip-extra-Sign-data-to-from-client.patch deleted file mode 100644 index 6a40caec3..000000000 --- a/Spigot-Server-Patches/Strip-extra-Sign-data-to-from-client.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Wed, 27 Feb 2019 22:18:40 -0500 -Subject: [PATCH] Strip extra Sign data to/from client - -modified clients can send abnormally large data from the client -to the server and it would get stored on the sign as sent. - -the client can barely render around 16 characters as-is, but formatting -codes can get it to be more than 16 actual length. - -Set a limit of 80 which should give an average of 16 characters 2 -sets of legacy formatting codes which should be plenty for all uses. - -This does not strip any existing data from the NBT as plugins -may use this for storing data out of the rendered area. - -it only impacts data sent to and from the client. - -Set -DPaper.maxSignLength=XX to change limit or -1 to disable - -diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 04344a371..9b857a8d1 100644 ---- a/src/main/java/net/minecraft/server/PlayerConnection.java -+++ b/src/main/java/net/minecraft/server/PlayerConnection.java -@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { - String[] lines = new String[4]; - - for (int i = 0; i < astring.length; ++i) { -+ // Paper start - cap line length - modified clients can send longer data than normal -+ if (astring[i].length() > TileEntitySign.MAX_SIGN_LINE_LENGTH && TileEntitySign.MAX_SIGN_LINE_LENGTH > 0) { -+ astring[i] = astring[i].substring(0, TileEntitySign.MAX_SIGN_LINE_LENGTH); -+ } -+ // Paper end - lines[i] = SharedConstants.a(astring[i]); //Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. - } - SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); -diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java -index c2bcbbbab..05fb2eea5 100644 ---- a/src/main/java/net/minecraft/server/TileEntitySign.java -+++ b/src/main/java/net/minecraft/server/TileEntitySign.java -@@ -0,0 +0,0 @@ - package net.minecraft.server; - - import com.mojang.brigadier.exceptions.CommandSyntaxException; -+ - import javax.annotation.Nullable; - - public class TileEntitySign extends TileEntity implements ICommandListener { -@@ -0,0 +0,0 @@ public class TileEntitySign extends TileEntity implements ICommandListener { - // Paper start - Strip invalid unicode from signs on load - private static final boolean keepInvalidUnicode = Boolean.getBoolean("Paper.keepInvalidUnicode"); // Allow people to keep their bad unicode if they really want it - private boolean privateUnicodeRemoved = false; -+ public static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); - // Paper end - - public TileEntitySign() { - super(TileEntityTypes.SIGN); - } - -+ // Paper start - public NBTTagCompound save(NBTTagCompound nbttagcompound) { -+ return save(nbttagcompound, false); -+ } -+ public NBTTagCompound save(NBTTagCompound nbttagcompound, boolean filterLines) { -+ // Paper end - super.save(nbttagcompound); - - for (int i = 0; i < 4; ++i) { -- String s = IChatBaseComponent.ChatSerializer.a(this.lines[i]); -+ // Paper start -+ String component = org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(lines[i]); -+ -+ if (filterLines && MAX_SIGN_LINE_LENGTH > 0 && component.length() > MAX_SIGN_LINE_LENGTH) { -+ component = component.substring(0, MAX_SIGN_LINE_LENGTH); -+ } -+ -+ String s = org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(component)[0]); -+ // Paper end - - nbttagcompound.setString("Text" + (i + 1), s); - } -@@ -0,0 +0,0 @@ public class TileEntitySign extends TileEntity implements ICommandListener { - } - - public NBTTagCompound aa_() { -- return this.save(new NBTTagCompound()); -+ return this.save(new NBTTagCompound(), true); // Paper - filter lines - } - - public boolean isFilteredNBT() { --- \ No newline at end of file