Skip to content
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

Weird characters when pasting in WIndows Terminal #10572

Closed
speller opened this issue Jul 7, 2021 · 10 comments
Closed

Weird characters when pasting in WIndows Terminal #10572

speller opened this issue Jul 7, 2021 · 10 comments
Labels
Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-No-Repro We couldn't get this to happen, or it stopped happening entirely.

Comments

@speller
Copy link

speller commented Jul 7, 2021

Windows Terminal version (or Windows build number)

1.8.1521.0, 10.0.21390.2025

Other Software

No response

Steps to reproduce

When I run the following command in Ubuntu 20 from under Windows Terminal:

docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk:alpine gcloud auth login

I'm getting the following input when pasting the key:

Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=<long URL>

Enter verification code: ^[[200~<real pasted text>^[[201~

The command fails to process this input. I'm pasting the <real pasted text> but it is actually entered enveloped by ^[[200~ and ^[[201~ symbols.

ERROR: gcloud crashed (InvalidGrantError): (invalid_grant) Malformed auth code.

How to fix that?

Expected Behavior

Command works

Actual Behavior

Command fails

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jul 7, 2021
@skyline75489
Copy link
Collaborator

Interesting report! This is caused by "bracketed paste mode" (see #395), which is only enabled after the shell/application deliberately asks the terminal to enable this feature.

For more context, what is the shell you're using?

@speller
Copy link
Author

speller commented Jul 7, 2021

I started a new shell tab window and it worked as expected so I can not reproduce it now....
I'm using the bash shell but the script's shebang is #!/usr/bin/env sh. I tried to add printf "\e[?2004l" or set enable-bracketed-paste off to my script but it didn't help.

@zadjii-msft
Copy link
Member

skyline75489 is right, those characters are the bracketed paste sequences.

so I can not reproduce it now....

Well shucks. I'm gonna close this for now - if you run into a way to reliably reproduce this, feel free to comment here and we can reopen.

@zadjii-msft zadjii-msft added the Resolution-No-Repro We couldn't get this to happen, or it stopped happening entirely. label Jul 7, 2021
@yellowpattern
Copy link

I am seeing this exact same issue.

@ivsanro1
Copy link

ivsanro1 commented Mar 8, 2023

One hacky workaround to disable bracketed paste in the current terminal (the one in which you'll be running the gcloud auth command) is to run:

printf '\e[?2004l'

And then the sequences ^[[200~ and ^[[201~ should not appear anymore when pasting

@Artim96
Copy link

Artim96 commented Jul 30, 2023

I'm surprised this couldn't be reproduced. This has been a problem for me since day one of using the Terminal. It doesn't happen when using e.g. PowerShell or CMD through it, but any Linux shell will do that, unless you e.g. paste the text into emacs or the sorts. It also doesn't matter if it's the local Debian WSL or any Linux system accessed through ssh. Using Ctrl+Shift+V instead of using Ctrl+V as some recommend doesn't help, as I don't use anything else. And going to each systems ~/.inputrc to enter "set enable-bracketed-paste off" isn't really an option and shouldn't be the solution, as it very much seems to be a fault of the Terminal app. Maybe @zadjii-msft can re-open this issue, as it's very much reproducible and should finally be fixes after so many years.

@ersjim
Copy link

ersjim commented Nov 20, 2023

For me it only happens when I ssh into another linux server from WSL.

@christosg88
Copy link

I have the same issue when I paste with right click.
I'm only using the MS terminal to ssh into a linux machine so I'm not sure if it's exclusively there when in ssh, but it still happens.
When I paste, I see these characters getting appended to whatever was pasted 01~, but it doesn't happen always.

I never had this issue with Putty, so it must be an issue with MS terminal.

This issue should be re-opened.

@bessone
Copy link

bessone commented Nov 7, 2024

From a few days the same thing as @christosg88 has happened to me, via terminal with PowerShell I open an ssh session on remote linux machines and the paste has this behavior.
But only for a couple of days, before it always worked. Has there been any update to terminal or SSH/Powershell?

@bessone
Copy link

bessone commented Nov 7, 2024

Small update: I tried in terminal with WSL and it works, so surely the problem is not with terminal, but with openssh of powershell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-No-Repro We couldn't get this to happen, or it stopped happening entirely.
Projects
None yet
Development

No branches or pull requests

9 participants