Skip to content

Commit 013d163

Browse files
authored
Filter out disallowed control chars (#14057)
1 parent 4b3b397 commit 013d163

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

paper-server/patches/sources/net/minecraft/commands/Commands.java.patch

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
StackTraceElement[] stackTrace = e.getStackTrace();
102102

103103
for (int i = 0; i < Math.min(stackTrace.length, 3); i++) {
104-
@@ -366,7 +_,11 @@
104+
@@ -366,12 +_,16 @@
105105
return ContextChain.tryFlatten(command.getContext().build(commandString))
106106
.orElseThrow(() -> CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(command.getReader()));
107107
} catch (CommandSyntaxException e) {
@@ -114,6 +114,12 @@
114114
if (e.getInput() != null && e.getCursor() >= 0) {
115115
int cursor = Math.min(e.getInput().length(), e.getCursor());
116116
MutableComponent context = Component.empty()
117+
.withStyle(ChatFormatting.GRAY)
118+
- .withStyle(s -> s.withClickEvent(new ClickEvent.SuggestCommand("/" + commandString)));
119+
+ .withStyle(s -> s.withClickEvent(new ClickEvent.SuggestCommand("/" + net.minecraft.util.StringUtil.filterText(commandString)))); // Paper - Filter out disallowed control chars
120+
if (cursor > 10) {
121+
context.append(CommonComponents.ELLIPSIS);
122+
}
117123
@@ -383,7 +_,17 @@
118124
}
119125

0 commit comments

Comments
 (0)