mojira.dev
MC-265927

Edit box length restrictions can result in unpaired surrogate characters

The length restriction on edit boxes can result in unpaired surrogate characters.

Reproduction

  1. Open the world creation screen.

  2. 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.

Attachments

Comments 0

No comments.

+merlan #flirora

eowyn36

Confirmed

Platform

Normal

Input, UI

gui, gui-textbox

1.20.2, 23w42a, 23w44a

1.20.3 Pre-Release 1

Retrieved