Conversation
The window title set with OSC 0 or 2 comes from terminal output, and embedders typically show it in the page or window title. The title was taken from the raw data with a regex that also captured C0 control characters and did not bound its length. Drop C0 control characters and DEL from the title, as a VT parser ignores them inside an OSC string, and ignore titles longer than 255 UTF-8 bytes, the limit native Ghostty applies (windowTitle in termio/stream_handler.zig).
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.
Summary
onTitleChangedelivered the OSC 0/2 payload exactly as a regex matched it in the raw data: including C0 control characters, and with no length limit. Embedders typically put the title straight intodocument.titleor their own UI.Change
windowTitleinsrc/termio/stream_handler.zig).The WASM currently ignores
.window_title, so tracking the title there would be the fuller fix; this keeps the change in TypeScript. #169 also refactorscheckForTitleChange, and #176 adds title tests toterminal.test.ts; happy to rebase onto whichever lands first.Testing
terminal.test.ts: control characters are stripped, and an over-long title is ignored while the previous one is kept.bun run fmt && bun run lint && bun run typecheck && bun test && bun run buildall pass, with tests run against a WASM built from this tree (Zig 0.15.2).ESC]2;safe\rspoofed\btitle BELproduces the titlesafespoofedtitle, and a 256-byte title leaves it unchanged.