|
3 | 3 | import io.papermc.paper.configuration.GlobalConfiguration;
|
4 | 4 | import io.papermc.paper.console.BrigadierCompletionMatcher;
|
5 | 5 | import io.papermc.paper.console.BrigadierConsoleParser;
|
| 6 | +import net.kyori.adventure.text.Component; |
| 7 | +import net.kyori.adventure.text.format.NamedTextColor; |
6 | 8 | import net.minecraft.server.dedicated.DedicatedServer;
|
| 9 | +import net.minecraft.util.StringUtil; |
7 | 10 | import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
| 11 | +import org.bukkit.Bukkit; |
8 | 12 | import org.bukkit.craftbukkit.command.ConsoleCommandCompleter;
|
9 | 13 | import org.jline.reader.LineReader;
|
10 | 14 | import org.jline.reader.LineReaderBuilder;
|
@@ -45,10 +49,24 @@ protected void runCommand(String command) {
|
45 | 49 | // terminals interpret pressing [enter] and pasting a multi-line string differently,
|
46 | 50 | // the latter makes the line reader read it as a single line - and we don't want that
|
47 | 51 | // https://github.com/PaperMC/Paper/issues/13006
|
| 52 | + outer: |
48 | 53 | for (String line : command.split("\n")) {
|
49 | 54 | if (line.isEmpty()) {
|
50 | 55 | continue;
|
51 | 56 | }
|
| 57 | + |
| 58 | + for (char character : line.toCharArray()) { |
| 59 | + if (!StringUtil.isAllowedChatCharacter(character)) { |
| 60 | + Bukkit.getConsoleSender().sendMessage( |
| 61 | + Component.text() |
| 62 | + .append(Component.text("Illegal console input character: 0x")) |
| 63 | + .append(Component.text(Integer.toHexString(character))) |
| 64 | + .color(NamedTextColor.RED) |
| 65 | + ); |
| 66 | + continue outer; |
| 67 | + } |
| 68 | + } |
| 69 | + |
52 | 70 | this.server.handleConsoleInput(line, this.server.createCommandSourceStack());
|
53 | 71 | }
|
54 | 72 | }
|
|
0 commit comments