-
Bug
-
Resolution: Fixed
-
23w40a
-
None
-
Confirmed
-
Commands
-
Important
-
Platform
Step(s) to reproduce:
- Enter the following command in chat:
/tellraw @a {text: hello}
Result: It displays hello in chat.
Expected result: It errors out, stating it's malformed JSON.
Code analysis:
The net.minecraft.network.chat.Component.Serializer::fromJson(com.mojang.brigadier.StringReader) method now calls com.google.gson.JsonParser::parseReader, and while it calls setLenient(false) beforehand, the JsonParser::parseReader method sets it back to true, which causes it to accept malformed JSON, such as unquoted strings.
// net.minecraft.network.chat.Component.Serializer public static MutableComponent fromJson(com.mojang.brigadier.StringReader stringReader) { try { // ... jsonReader.setLenient(false); JsonElement jsonElement = JsonParser.parseReader(jsonReader); // ... } // ... }
// com.google.gson.JsonParser public static JsonElement parseReader(JsonReader reader) throws JsonIOException, JsonSyntaxException { // ... reader.setLenient(true); // ... }