2022-07-28 03:57:50 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2022-11-26 04:34:27 +00:00
|
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
|
|
Date: Fri, 25 Nov 2022 22:25:24 -0600
|
2022-07-28 03:57:50 +00:00
|
|
|
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
|
2022-11-26 04:34:27 +00:00
|
|
|
index 10b133e95dbf2edb87764ea9d07974d8146bbed0..de1c251a0f4301beb2c6fd04dc25145c71887e27 100644
|
2022-07-28 03:57:50 +00:00
|
|
|
--- 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 {
|
2022-11-26 04:34:27 +00:00
|
|
|
// Paper start
|
|
|
|
if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) {
|
|
|
|
@@ -53,8 +55,11 @@ public class ComponentUtils {
|
2022-07-28 03:57:50 +00:00
|
|
|
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 {
|