mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-27 07:05:39 +00:00
38 lines
1.9 KiB
Diff
38 lines
1.9 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Video <videogamesm12@gmail.com>
|
||
|
Date: Mon, 28 Mar 2022 16:49:17 -0600
|
||
|
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 8f4c83837d0b01a3dbca2607ea718c371db48ef4..fe2717679f84fbef1b8ff1f9a3c3bf0fba8965f1 100644
|
||
|
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||
|
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||
|
@@ -37,8 +37,11 @@ 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 instanceof ContextAwareComponent ? ((ContextAwareComponent)text).resolve(source, sender, depth + 1) : text.plainCopy();
|
||
|
|
||
|
@@ -46,8 +49,12 @@ 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 ? new TextComponent("") : result;
|
||
|
+ // Scissors end
|
||
|
}
|
||
|
|
||
|
private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|