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#setTexttruncates the string tomaxLengthUTF-16 code units, without regard to whether doing so would split the text in the middle of a surrogate pair.Similarly,
TextFieldWidget#writetruncates the string inserted so that the new text is at mostmaxLengthcode units long, whether or not doing so would split a surrogate pair.
Attachments
Comments 0
No comments.