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 com.mojang.brigadier.context.CommandContext;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; 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.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -36,8 +35,12 @@ public class RunCommand extends Command {
future.thenApply(tag -> { future.thenApply(tag -> {
if (!tag.contains("LastOutput") || !(tag.get("LastOutput") instanceof StringTag)) return tag; if (!tag.contains("LastOutput") || !(tag.get("LastOutput") instanceof StringTag)) return tag;
final String outputJson = ((StringTag) tag.get("LastOutput")).getValue(); final String outputJson = ((StringTag) tag.get("LastOutput")).getValue();
try {
final Component output = GsonComponentSerializer.gson().deserialize(outputJson); final Component output = GsonComponentSerializer.gson().deserialize(outputJson);
source.sendOutput(output); source.sendOutput(output);
} catch (Exception exception) {
}
return tag; return tag;
}); });