From 5ca9ce20995b4eaff8b06a003a7e989d2cd72978 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Sun, 12 Jun 2022 00:35:09 -0500 Subject: [PATCH] =?UTF-8?q?Last=20patch=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-data/dev-imports.txt | 3 +- ...t-oversized-components-from-updating.patch | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 patches/server/0028-Reject-oversized-components-from-updating.patch diff --git a/build-data/dev-imports.txt b/build-data/dev-imports.txt index 93991a1..aaa2555 100644 --- a/build-data/dev-imports.txt +++ b/build-data/dev-imports.txt @@ -10,4 +10,5 @@ # minecraft net/minecraft/world/level/entity/LevelEntityGetter.java minecraft net/minecraft/world/ContainerHelper -minecraft net/minecraft/network/chat/contents/NbtContents \ No newline at end of file +minecraft net/minecraft/network/chat/contents/NbtContents +minecraft net/minecraft/network/chat/ComponentUtils \ No newline at end of file diff --git a/patches/server/0028-Reject-oversized-components-from-updating.patch b/patches/server/0028-Reject-oversized-components-from-updating.patch new file mode 100644 index 0000000..b76aaea --- /dev/null +++ b/patches/server/0028-Reject-oversized-components-from-updating.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Telesphoreo +Date: Sun, 12 Jun 2022 00:33:21 -0500 +Subject: [PATCH] Reject oversized components from updating + + +diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java +index 9d3449dd92bbbef91b627caba752b87d8209011d..26c0438e8d4ef5ccfc53fbd5233bb6b7b0b1fc60 100644 +--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java ++++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java +@@ -39,8 +39,10 @@ public class ComponentUtils { + } + + public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException { ++ // Scissors start - Reject oversized components ++ MutableComponent result; + if (depth > 100) { +- return text.copy(); ++ result = text.copy(); + } else { + MutableComponent mutableComponent = text.getContents().resolve(source, sender, depth + 1); + +@@ -48,8 +50,11 @@ public class ComponentUtils { + mutableComponent.append(updateForEntity(source, component, sender, depth + 1)); + } + +- return mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); ++ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); + } ++ // Would the resulting component exceed 65535 bytes when encoded as a string? ++ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result; ++ // Scissors end + } + + private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {