From 68c343e11438fae66824a85b015c02e70eb2da8d Mon Sep 17 00:00:00 2001 From: Chip <65827213+ChipmunkMC@users.noreply.github.com> Date: Sat, 21 Jan 2023 15:13:37 -0500 Subject: [PATCH] Fix an exploit related to the run command --- .../land/chipmunk/chipmunkbot/commands/RunCommand.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/RunCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/RunCommand.java index 9410f34..234fb18 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/commands/RunCommand.java +++ b/src/main/java/land/chipmunk/chipmunkbot/commands/RunCommand.java @@ -9,7 +9,6 @@ import static com.mojang.brigadier.arguments.StringArgumentType.getString; import com.mojang.brigadier.context.CommandContext; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.StringTag; import java.util.concurrent.CompletableFuture; @@ -36,8 +35,12 @@ public class RunCommand extends Command { future.thenApply(tag -> { if (!tag.contains("LastOutput") || !(tag.get("LastOutput") instanceof StringTag)) return tag; final String outputJson = ((StringTag) tag.get("LastOutput")).getValue(); - final Component output = GsonComponentSerializer.gson().deserialize(outputJson); - source.sendOutput(output); + + try { + final Component output = GsonComponentSerializer.gson().deserialize(outputJson); + source.sendOutput(output); + } catch (Exception exception) { + } return tag; });