You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 06b1a54
Browse filesBrowse the repository at this point in the historyBrowse files
fix(composer): refuse control characters committed as text
Corrects the range 4bfb6ff8 inferred with the character that was observed.
That commit refused the private-use function-key character AppKit puts in
a caret key's NSEvent (Right Arrow is U+F703) and said the box the user
saw was, by every sign, that character. The persisted draft shows
otherwise: read from a copy of the desktop build's WebKit local storage,
its last paragraph is a single text node of fourteen U+001D characters,
one per Right Arrow press, and the draft's text field ends in the same
fourteen. U+001D is the C0 control ASCII calls the Group Separator,
nowhere near the guarded block, so both seams let it through and the box
still appeared.
The character is a keyboard-layout translation surviving into text. An
in-process AppKit and Carbon probe gives U+001D for Right Arrow's keycode
from CGEvent.keyboardGetUnicodeString and UCKeyTranslate, while a real
NSEvent built from the press carries U+F703: AppKit remaps the arrows
(U+001C through U+001F), Home and End (U+0001 and U+0004), Page Up and
Page Down (U+000B and U+000C) and the function keys to the private-use
block. WebKit's KeyEventMac.mm blanks a key event's text only when its
single character lies in U+F700 through U+F7FF, so a hardware Right Arrow
inserts nothing at the end of the text, while a raw layout translation,
which only a directly constructed key event carries in its characters,
matches no key binding and is committed through insertText as ordinary
text. The boxes are therefore inferred to come from a synthetic key event
rather than a physical press; whatever the source, a lone control
character is never prose and the composer refuses it.
CONTROL_CHARACTERS replaces FUNCTION_KEY_CHARACTERS and
controlCharacterText replaces functionKeyText. The class covers the whole
Unicode Control category as \p{Cc} (the C0 controls, DEL and the C1
controls U+0080 through U+009F, none of which a layout types or a font
draws) plus the private-use block; Biome's noControlCharactersInRegex
rule refuses explicit C0 escapes, and the category is the clearer
statement anyway. Tab, newline and carriage return, which typed text
legitimately holds, are excluded by a second regex. The all-or-nothing
semantics hold: text mixing a real character with a control character
passes untouched. Both seams stay: beforeinput cancels a cancelable
insertText whose data is control text so the DOM never changes, and
handleTextInput returns true for it without a transaction so an insertion
that arrived anyway is redrawn away. The paste, drop and programmatic
insert() paths and the two-transaction undo shape of the typed
conversions are untouched, and no typed-conversion rule runs for a
refused insertion. The comment now states the observed U+001D and its
origin first and keeps the private-use rationale as the secondary case.
docs/channels.md does not name the guarded characters and is unchanged.
Tests: the function-key table in EditableInput.test.tsx becomes a
control-character table adding U+001C through U+001F, U+0001, U+0004,
U+000B, U+000C, DEL and the C1 bounds U+0080 and U+009F, each refused at
both seams with the draft, DOM and caret unchanged and typing continuing;
the four caret-key contexts and the typed-conversion case commit Right
Arrow as U+001D beside U+F703; a new case asserts that a native tab,
newline and carriage return (read as a newline by ProseMirror's parser)
and the mixed string a\u001D are still inserted whole. MessageComposer
dispatches U+001D beside U+F703 and asserts nothing was sent; the
composer-formats journey commits U+001D beside U+F703 through
keyboard.insertText on Chromium and WebKit. The seventeen Vitest cases
and both browser journeys fail at 97b429fa, where U+001D lands in the
document, and pass with the fix. Both composer suites (264 tests), the
whole browser spec on both engines, tsc --noEmit and biome check
--error-on-warnings pass, the last reporting only its pre-existing note
that biome.json names schema 2.5.12 while 2.5.14 is installed.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Matt Toohey <[email protected]>
0 commit comments