-
Bug
-
Resolution: Fixed
-
1.20.2, 23w42a, 23w44a
-
Confirmed
-
Input, UI
-
Normal
-
Platform
The length restriction on edit boxes can result in unpaired surrogate characters.
Reproduction
- 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.
Code analysis
(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.