Repository navigation
Keep escape-sequence payloads out of Debug output - #185
Merged
Merged
Conversation
Debug.WriteLine reaches every Trace listener a host installs, and hosts bridge those into application logs. Two lines quoted text a program printed: - "Unknown OSC sequence" logged the text before the first ';'. With no ';' that is the whole OSC payload. It now logs the number when it is one, else only the length. - "Unknown CSI sequence" logged the identifier, whose intermediates the parser collects without a limit. A long one is now reported by its final byte and count. "Unhandled OSC command" logs the numeric id. The mode lines log only integers or enum names, so they stay. The test writes a sentinel through OSC, CSI, DCS, APC, PM, paste and character input and checks that a Trace listener never sees it. In a Debug build it also checks that the redacted lines did arrive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tomlm
approved these changes
Nov 1, 2026
JohnCampionJr
added a commit
to tomlm/Iciclecreek.Avalonia.Terminal
that referenced
this pull request
Nov 1, 2026
3.0.2 keeps escape-sequence payloads out of XTerm.NET's Debug output (tomlm/XTerm.NET#185), the library half of #201. 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.
Some of the parser's
Debug.WriteLinelines quote text taken from the output stream. A host that bridgesTrace.Listenersinto its logging then copies terminal data into its log. An OSC payload is program output: it can carry clipboard data (OSC 52), titles, hyperlinks, notification bodies or any text a program printed, including text from untrusted content such ascatof a file. This is the library-side counterpart of tomlm/Iciclecreek.Avalonia.Terminal#201, which stopped the control logging typed text.Changes
I audited all 17 Debug writes in
src/XTerm.NET(there are noTrace.*orConsole.*calls) and changed 3, all inInputHandler.cs:parts[0]: the text before the first;, or the whole payload when there is nonenon-numeric command, N charsidentifier(the parser collects any number of intermediates)final 'X' after N intermediatesOscCommandenum name(int)command, the numeric id (it was already safe; this keeps the OSC lines consistent)Kept: the mode lines in
InputHandler.csandInputHandler.Modes.cs(unknown or unhandled modes, Meta/Alt/Win32 toggles), which log anintmode or aTerminalModename, never stream text.BufferReflow.cs'sDebug.Asserthas no message. Nothing on the input-encoding side (Generate*Input, Paste, Kitty) logs anything.Test
DiagnosticOutputTestsadds aTraceListenerfor the test, removed infinally, and writesS3CR3T-sentinelthrough:PasteandGenerateCharInput.It asserts that the sentinel, its base64 and the run of intermediates never appear. Under
#if DEBUGit also asserts that the three redacted lines did arrive, so an empty capture can't pass. Restoring the raw OSC text turns it red, and so does lifting the CSI cap. It and the OSC, OSC passthrough, mode handling, private CSI dispatch and InputHandler tests pass 297/297. The full test project wasn't run.🤖 Generated with Claude Code