From b8c87c208f804fd92516168befc3c57072bc07b3 Mon Sep 17 00:00:00 2001 From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> Date: Mon, 13 Jul 2026 01:54:49 +0800 Subject: [PATCH] Filter out disallowed control chars --- .../sources/net/minecraft/commands/Commands.java.patch | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch index f235a2b3a084..504bc8204d7a 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -101,7 +101,7 @@ StackTraceElement[] stackTrace = e.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -366,7 +_,11 @@ +@@ -366,12 +_,16 @@ return ContextChain.tryFlatten(command.getContext().build(commandString)) .orElseThrow(() -> CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(command.getReader())); } catch (CommandSyntaxException e) { @@ -114,6 +114,12 @@ if (e.getInput() != null && e.getCursor() >= 0) { int cursor = Math.min(e.getInput().length(), e.getCursor()); MutableComponent context = Component.empty() + .withStyle(ChatFormatting.GRAY) +- .withStyle(s -> s.withClickEvent(new ClickEvent.SuggestCommand("/" + commandString))); ++ .withStyle(s -> s.withClickEvent(new ClickEvent.SuggestCommand("/" + net.minecraft.util.StringUtil.filterText(commandString)))); // Paper - Filter out disallowed control chars + if (cursor > 10) { + context.append(CommonComponents.ELLIPSIS); + } @@ -383,7 +_,17 @@ }