forked from chipmunkmc/chipmunkbot
Fix an exploit related to the run command
This commit is contained in:
parent
ec431febec
commit
68c343e114
1 changed files with 6 additions and 3 deletions
|
@ -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();
|
||||||
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;
|
return tag;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue