From 3a4b3ffd34f90392a1f4c491a9b72b5fbab58c6f Mon Sep 17 00:00:00 2001 From: Allink <44676012+allinkdev@users.noreply.github.com> Date: Thu, 18 Aug 2022 03:45:44 +0100 Subject: [PATCH] Refuse to convert legacy messages over 1k characters (#62) --- ...te-block-entity-tag-query-positions.patch} | 2 +- ...out-of-bound-chunks-crashing-server.patch} | 0 ...t-legacy-messages-over-1k-characters.patch | 22 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) rename patches/server/{0041-Validate-block-entity-tag-query-positions.patch => 0042-Validate-block-entity-tag-query-positions.patch} (92%) rename patches/server/{0042-Fix-out-of-bound-chunks-crashing-server.patch => 0043-Fix-out-of-bound-chunks-crashing-server.patch} (100%) create mode 100644 patches/server/0044-Refuse-to-convert-legacy-messages-over-1k-characters.patch diff --git a/patches/server/0041-Validate-block-entity-tag-query-positions.patch b/patches/server/0042-Validate-block-entity-tag-query-positions.patch similarity index 92% rename from patches/server/0041-Validate-block-entity-tag-query-positions.patch rename to patches/server/0042-Validate-block-entity-tag-query-positions.patch index ffb96e7..9125215 100644 --- a/patches/server/0041-Validate-block-entity-tag-query-positions.patch +++ b/patches/server/0042-Validate-block-entity-tag-query-positions.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Validate block entity tag query positions diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index d6aa46443b0ec9b02259222d8ee9a7ff0cec4ae7..dd80826c8ce1a9bb479eea383d84b71c8756a341 100644 +index a102586b42ac408a3f655f7c0d069ab0990ec7fc..dbf982c85ff361184a34b462bec331ac5b1a472c 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1252,7 +1252,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser diff --git a/patches/server/0042-Fix-out-of-bound-chunks-crashing-server.patch b/patches/server/0043-Fix-out-of-bound-chunks-crashing-server.patch similarity index 100% rename from patches/server/0042-Fix-out-of-bound-chunks-crashing-server.patch rename to patches/server/0043-Fix-out-of-bound-chunks-crashing-server.patch diff --git a/patches/server/0044-Refuse-to-convert-legacy-messages-over-1k-characters.patch b/patches/server/0044-Refuse-to-convert-legacy-messages-over-1k-characters.patch new file mode 100644 index 0000000..c3ecf61 --- /dev/null +++ b/patches/server/0044-Refuse-to-convert-legacy-messages-over-1k-characters.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Tue, 16 Aug 2022 18:14:16 +0100 +Subject: [PATCH] Refuse to convert legacy messages over 1k characters + + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +index 26d43c229caf9f8504af7071c3a61ec6da7e27ec..ecceb3fc7f822d826b4a789fe72a8cd08e90d60e 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +@@ -198,6 +198,11 @@ public final class CraftChatMessage { + } + + public static Component[] fromString(String message, boolean keepNewlines, boolean plain) { ++ // Scissors start - Refuse to convert legacy messages over 1k characters ++ if (message.length() > 1_000) { ++ return new Component[]{TextComponent.EMPTY}; ++ } ++ // Scissors end + return new StringMessage(message, keepNewlines, plain).getOutput(); + } +