Scissors/patches/removed/server/0015-Reject-oversized-components-from-updating.patch

33 lines
1.7 KiB
Diff
Raw Normal View History

2022-07-28 03:57:50 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Mon, 28 Mar 2022 16:49:17 -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
index 584a58659fae6ba3d8b53858890bc6ec509ffb0e..54a7dae26854d320d9e53f63eb411a85a2d78159 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,9 @@ public class ComponentUtils {
2022-07-28 03:57:50 +00:00
}
public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException {
+ MutableComponent result; // Scissors
2022-07-28 03:57:50 +00:00
if (depth > 100) {
- return text.copy();
+ result = text.copy(); // Scissors
2022-07-28 03:57:50 +00:00
} else {
2022-11-26 04:34:27 +00:00
// Paper start
if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) {
@@ -53,8 +54,9 @@ 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)); // Scissors
2022-07-28 03:57:50 +00:00
}
+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result; // Scissors
2022-07-28 03:57:50 +00:00
}
private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {