Skip to content

Don't trim bracketed pastes set via OSC52 #19067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Jun 24, 2025

  • Moves clipboard writing from ControlCore to TerminalPage.
    This requires adding a bunch of event types and logic.
  • Store the clipboard counter and compare it during pastes.

Closes microsoft/edit#279

Validation Steps Performed

  • Launch Microsoft Edit and copy text with a trailing newline
  • Paste it with Ctrl+Shift+V
  • It's pasted as it was copied ✅

@lhecker lhecker added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. Issue-Task It's a feature request, but it doesn't really need a major design. labels Jun 24, 2025
@j4james
Copy link
Collaborator

j4james commented Jul 1, 2025

For the record, this seems wrong to me (assuming I've understood the change correctly). Because trimming carriage returns from the end of a paste is in some ways a security feature, and this is disabling that protection in the one situation where it could be most helpful.

That said, this is already a problem with multiline pastes (see #13014), so it's not any worse than it was before. It just feels like in both of these cases that we're misleading users. We have options to trim trailing whitespace, and warn on multiline paste, and they're labelled as OFF or ON, but they're actually implemented as OFF and MAYBE. Perhaps there's a need for a third option for the more paranoid.

Not that I'm expecting you to solve that now. I just wanted to note my concern.

@lhecker
Copy link
Member Author

lhecker commented Jul 1, 2025

But this PR will only skip trimming if the paste is bracketed (the || !bracketedPaste check). Shouldn't shells aware of bracketed paste avoid submitting the input unless the user additionally presses enter (= this PR doesn't make the situation worse)?

@j4james
Copy link
Collaborator

j4james commented Jul 1, 2025

Shouldn't shells aware of bracketed paste avoid submitting the input unless the user additionally presses enter

First off, neither the cmd shell nor powershell are aware of bracketed paste. And even in shells that do support bracketed paste, it can be bypassed if the attacker has access to your input (i.e. you've connected to a remote system or application, rather than just viewing a malicious file).

But as I said, this is already an issue, so this PR doesn't make it any worse. It's just another vector that would need to be addressed if we ever did want to fix the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy & Paste misses terminal line break
2 participants