The length restriction on edit boxes can result in unpaired surrogate characters.
- Open the world creation screen.
- Paste a𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐𐑐 (an ‘a’ followed by repeated U+10450 characters) into the world name box
Intended behavior: The text contents cut off after one of the U+10450s.
Actual behavior: The contents end with an unpaired surrogate character.
(For the 1.20.2 code, using Yarn version 1.20.2+build.1.)
- TextFieldWidget#setText truncates the string to maxLength UTF-16 code units, without regard to whether doing so would split the text in the middle of a surrogate pair.
- Similarly, TextFieldWidget#write truncates the string inserted so that the new text is at most maxLength code units long, whether or not doing so would split a surrogate pair.