-
Bug
-
Resolution: Won't Fix
-
None
-
24w10a
-
None
-
Confirmed
-
(Unassigned)
The JSON parser used by components like custom_name, lore, written_book_content, as well as sign block entity data, is configured too lenient. This allows cursed chat components that wouldn't work in other places such as /tellraw
Relates to MC-265702
How to reproduce:
- Try running a command like this (notice the = and the missing quotes)
/give @p stone[custom_name="{text=Test,'italic':0}"]
Notice that the command is valid and you get an item named "Test" not italic
- Inspect the given item
/data get entity @s SelectedItem
- Notice that the actual (corrected) chat component is {"italic":false,"text":"Test"}
- Try to use the same chat component in /tellraw
/tellraw @s {text=Test,'italic':0}
This command is invalid as expected and mentions that it is not using the lenient parser
Code analysis:
Commands such as /tellraw use ParserUtils.parseJson, which in turns sets jsonReader.setLenient(false).
In contrast, the custom_name data component uses ComponentSerialization.FLAT_CODEC, which uses com.google.gson.JsonParser.parseString() without setting lenient to false.