Escape sequences are not stripped from the tab title #16448

Open
opened 2026-01-31 05:12:31 +00:00 by claunia · 0 comments
Owner

Originally created by @j4james on GitHub (Jan 20, 2022).

Windows Terminal version

1.12.3472.0

Windows build number

10.0.19041.1415

Other Software

No response

Steps to reproduce

  1. Edit the settings.json file.
  2. Set the default tab title with an escape sequence like this: "tabTitle": "\u001b[41m"
  3. Start a cmd shell

Expected Behavior

The escape character should be stripped from the title.

Actual Behavior

The escape character is left in the title when propagated over conpty, so it ends up being interpreted as a background color change in the terminal.

image

We do already sanitize the title in DoSrvSetConsoleTitleW, which covers title changes via the console API, but in this case the CONSOLE_INFORMATION::SetTitle method is being called directly from the AllocateConsole method on startup:

7061c54ac5/src/host/consoleInformation.cpp (L130)

My suggestion is we move the sanitization from DoSrvSetConsoleTitleW into the CONSOLE_INFORMATION::SetTitle method, so we can be sure it's applied in all cases.

Originally created by @j4james on GitHub (Jan 20, 2022). ### Windows Terminal version 1.12.3472.0 ### Windows build number 10.0.19041.1415 ### Other Software _No response_ ### Steps to reproduce 1. Edit the settings.json file. 2. Set the default tab title with an escape sequence like this: `"tabTitle": "\u001b[41m"` 3. Start a cmd shell ### Expected Behavior The escape character should be stripped from the title. ### Actual Behavior The escape character is left in the title when propagated over conpty, so it ends up being interpreted as a background color change in the terminal. ![image](https://user-images.githubusercontent.com/4181424/150380055-929963d1-dbb2-469c-9c4f-d8914c5cb626.png) We do already sanitize the title in `DoSrvSetConsoleTitleW`, which covers title changes via the console API, but in this case the `CONSOLE_INFORMATION::SetTitle` method is being called directly from the `AllocateConsole` method on startup: https://github.com/microsoft/terminal/blob/7061c54ac59c8469a00a6ce36334ba379ff704e9/src/host/consoleInformation.cpp#L130 My suggestion is we move the sanitization from `DoSrvSetConsoleTitleW` into the `CONSOLE_INFORMATION::SetTitle` method, so we can be sure it's applied in all cases.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16448