Fix an exploit related to the run command

This commit is contained in:
Chipmunk 2023-01-21 15:13:37 -05:00
parent ec431febec
commit 68c343e114

View file

@ -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;
});