Repository navigation
Conversation
…ne ESC readRawChar() discarded parametrised cursor keys such as ESC[1D as device reports, leaked SS3 arrows (ESC O A) as typed characters, and surfaced bracketed-paste markers as unknown tokens; readKeyWithTimeout() returned '' for a lone ESC and treated chatter as activity. Normalise CSI/SS3 cursor keys to the bare arrow form, treat paste markers as chatter, return chatter as a soft timeout, and report a lone ESC as 'ESC'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…line editing The three terminal line readers split UTF-8 characters (cancelling the input dialog or dropping the character), left the rest of a multi-line paste queued to run against later prompts, double-submitted on CRLF in LineShell, and ignored cursor keys in the boxed dialog. Add a shared codepoint-safe TerminalLineEditor and TerminalLineHistory, reassemble UTF-8 in readRawChar(), drain a paste burst after submit or cancel, treat CRLF as one submit, and honor mid-line cursor editing. Depends on awehttam#485. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TITLE: Terminal: UTF-8-safe shared line editor, paste-leak containment, mid-line editing
Depends on #485 (#485, "Terminal: decode parametrised/SS3 cursor keys, bracketed paste and lone ESC"). This branch is stacked on #485's commit; review or merge #485 first.
Problem
The terminal server has three separate line readers:
BbsSession::readTelnetLine(),TelnetUtils::showInputDialog()andLineShell::readPromptLine(). Each implements editing differently:TelnetUtils::readRawChar()returns single bytes, so a UTF-8 character is split. InshowInputDialog()its lead byte cancels the dialog;readPromptLine()silently drops it.LineShelltreats CR and LF as separate submits, so CRLF submits twice.Impact
Non-ASCII input cancels dialogs or disappears, pasted text leaks into later prompts (including password fields), and CRLF clients double-submit.
Repair
telnet/src/TerminalLineEditor(codepoint-safe insert/delete, cursor motion, max length, submit/cancel) andTerminalLineHistory(per-prompt recall), shared byshowInputDialog()andLineShell::readPromptLine().TelnetUtils::readRawChar()reassembles a UTF-8 lead byte and its continuation bytes into one character; truncated sequences don't hang.BbsSession::drainPendingInput()discards input already queued from the same paste burst, so it cannot leak into the next prompt.Proof
tests/Unit/TerminalLineEditorTest.phpandtests/Unit/TerminalLineHistoryTest.php(pure unit tests).tests/Unit/TerminalLineInputPipelineTest.php: realBbsSession,TelnetUtilsandLineShellreaders over a socket pair. It covers:TerminalKeyDecodingTest. Without this change the new classes are absent, so the tests cannot run. The rest oftests/Unitis unchanged.