Curly and square brackets are replaced with ANSI escapes 0x1b and 0x1d when at the start of pasted text in WSL #23153

Open
opened 2026-01-31 08:33:49 +00:00 by claunia · 0 comments
Owner

Originally created by @sylann on GitHub (Apr 14, 2025).

Windows Terminal version

1.22.10731.0

Windows build number

10.0.22631.0

Other Software

No response

Steps to reproduce

  1. Copy some text starting with either of the following characters: {}[]
  2. Paste using CTRL+v or SHIFT+CTRL+v (depending on your shortcut for the Terminal's action "Paste")
  3. Observe the pasted text is not identical to the copied text, as described in the table below
copied pasted Hex Codes
{ ^[ 0x1B
} ^] 0x1D
[ ^[ 0x1B
] ^] 0x1D
][ ^][ 0x1D 0x5B
[] ^[] 0x1B 0x5D
}{ ^]{ 0x1D 0x7B
{} ^[} 0x1B 0x7D

Notes:

  • I have only tested with parentheses (), square brackets [], and curly braces {}.
  • The problem does not happen in Powershell, only in a WSL 2 terminal (tested with 2 distributions: Arch Linux, and Debian).
  • It only happens for the first character of the pasted text (e.g. {}[] becomes ^[}[], NOT ^[^]^[^]).
  • It only happens when using the shortcut CTRL+v (not when using Right click for example).
  • EDIT: The problem does not happen when manually triggering the "Paste" action from "Toggle command palette"
  • EDIT: The problem does not happen when the shortcut for "Paste" is ALT+e for example
    • The issue might be caused by the fact that CTRL is pressed

Expected Behavior

Pasted text is identical to copied text.

Actual Behavior

Pasted text is different from copied text.

In case you are wondering, I discovered this bug by pasting a complex password from a password db, into the terminal to ssh into a server.

The password happened to start with a bracket.

Originally created by @sylann on GitHub (Apr 14, 2025). ### Windows Terminal version 1.22.10731.0 ### Windows build number 10.0.22631.0 ### Other Software _No response_ ### Steps to reproduce 1. Copy some text starting with either of the following characters: `{}[]` 2. Paste using <kbd>CTRL</kbd>+<kbd>v</kbd> or <kbd>SHIFT</kbd>+<kbd>CTRL</kbd>+<kbd>v</kbd> (depending on your shortcut for the Terminal's action "Paste") 3. Observe the pasted text is not identical to the copied text, as described in the table below | copied | pasted | Hex Codes | | ------ | ------ | ----------- | | `{` | `^[` | `0x1B` | | `}` | `^]` | `0x1D` | | `[` | `^[` | `0x1B` | | `]` | `^]` | `0x1D` | | `][` | `^][` | `0x1D 0x5B` | | `[]` | `^[]` | `0x1B 0x5D` | | `}{` | `^]{` | `0x1D 0x7B` | | `{}` | `^[}` | `0x1B 0x7D` | Notes: - I have only tested with parentheses `()`, square brackets `[]`, and curly braces `{}`. - The problem does not happen in Powershell, only in a WSL 2 terminal (tested with 2 distributions: Arch Linux, and Debian). - It only happens for the **first character** of the pasted text (e.g. `{}[]` becomes `^[}[]`, NOT `^[^]^[^]`). - It only happens when using the shortcut <kbd>CTRL</kbd>+<kbd>v</kbd> (not when using Right click for example). - EDIT: The problem does not happen when manually triggering the "Paste" action from "Toggle command palette" - EDIT: The problem does not happen when the shortcut for "Paste" is <kbd>ALT</kbd>+<kbd>e</kbd> for example - **The issue might be caused by the fact that <kbd>CTRL</kbd> is pressed** ### Expected Behavior Pasted text is identical to copied text. ### Actual Behavior Pasted text is different from copied text. In case you are wondering, I discovered this bug by pasting a complex password from a password db, into the terminal to ssh into a server. The password happened to start with a bracket.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 08:33:49 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23153