DOM: typed non-ASCII characters reach onTextInput truncated, and Ctrl or Meta letters reach it as text #187
Labels
No labels
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Graphics#187
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two problems with the text the DOM backend takes from
keydown, both on the path fromadditional/dom-env.js:557-563to__crafterDom_keyDown(implementations/Crafter.Graphics-Window.cpp:2050-2084), at852ae8a.Non-ASCII keys arrive truncated
dom-env.js:560passese.key.lengthas the key's length. That counts UTF-16 code units, but__writeUtf8(:42) wrote the key as UTF-8, so for anything outside ASCII the length is too short. 'é' is one unit and two bytes, soonTextInputgets the lone lead byteC3; '€' becomesE2; a key that produces an emoji (two units, four bytes) gets its first two bytes. AnInputFieldthen holds invalid UTF-8.e.code.lengthis right only because codes are ASCII.Fix: pass the UTF-8 byte length, for instance by having
__writeUtf8return it with the pointer.Ctrl and Meta letters become text
__crafterDom_keyDownforwards any one-byte printable key toonTextInput(Window.cpp:2079) without looking at the modifiers, so Ctrl+C, Ctrl+V, Ctrl+A or Cmd+Z in anInputFieldalso types 'c', 'v', 'a' or 'z', besides firingonRawKeyDown. On Win32 those keys arrive as control characters, 0x01 to 0x1A, which theWM_CHARhandler drops.Fix: pass the modifiers along and skip the text when Ctrl or Meta is down without AltGr. Browsers on Windows report AltGr as Ctrl+Alt, and
e.getModifierState("AltGraph")tells them apart, so AltGr+E still types '€'.Found while reviewing
claude/win32-title.