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 in place of terminal escape sequences on Windows Console #474

Open
BuriedInTheGround opened this issue Dec 26, 2022 · 1 comment · May be fixed by #475
Open

Weird characters in place of terminal escape sequences on Windows Console #474

BuriedInTheGround opened this issue Dec 26, 2022 · 1 comment · May be fixed by #475

Comments

@BuriedInTheGround
Copy link
Contributor

Environment

  • OS: Windows 10 Pro
  • age version: v1.1.1

What were you trying to do

I was trying to encrypt a file with a passphrase.

What happened

On both Windows PowerShell and cmd.exe, terminal escape sequences do not work by default. As a result, I obtained the following output, containing weird characters on screen.

age-escape-sequences-issue-powershell
age-escape-sequences-issue-cmd

As a side note, I actually discovered this issue while trying to use the same functions as yours to ask for a passphrase. I strongly believe that this behavior is present since the introduction of escape sequences in 349ed5e. This commit post-dates age version v1.0.0, so it may be the case that not many people have encountered this issue, but I think that it would negatively impact the UX for Windows users from now on (indeed, v1.1.0 and v1.1.1 just came out).

I'm going to make a PR to address this issue as a follow-up.

P.S.: sorry for not disclosing this issue before the v1.1.0 release, I didn't see it coming!

BuriedInTheGround added a commit to BuriedInTheGround/age that referenced this issue Dec 26, 2022
If possible, we enable virtual terminal processing, which is necessary
for using terminal escape sequences on instances of the Windows Console.
When enabling virtual terminal processing fails, we completely avoid
using escape sequences to prevent weird characters to be printed to the
console.

Fixes FiloSottile#474
FiloSottile pushed a commit to BuriedInTheGround/age that referenced this issue Apr 22, 2023
If possible, we enable virtual terminal processing, which is necessary
for using terminal escape sequences on instances of the Windows Console.
When enabling virtual terminal processing fails, we completely avoid
using escape sequences to prevent weird characters to be printed to the
console.

Fixes FiloSottile#474
@clach04
Copy link

clach04 commented Nov 24, 2024

Still an issue with age v1.2.0. NOTE rage 0.11.0 does NOT have this issue.

Occurs for passphrase encryption both when entering a password and also auto-generating a passphrase. Spurious control characters prepended to messages that are displayed in Windows CMD:

C:\code\enc\age>age.exe --version
v1.2.0

C:\code\enc\age>age.exe  --decrypt -i testdata\example_keys.txt testdata\example.age | age.exe --encrypt --passphrase -o testdata\copy_example.age
Enter passphrase (leave empty to autogenerate a secure one):
?[F?[Kage: using autogenerated passphrase "collect-pool-uphold-bacon-movie-medal-whisper-goose-spider-obvious"

C:\code\enc\age>age.exe  --decrypt -i testdata\example_keys.txt testdata\example.age | age.exe --encrypt --passphrase -o testdata\copy_example.age
Enter passphrase (leave empty to autogenerate a secure one):
?[F?[KConfirm passphrase:
?[F?[K

On screen the "?" look like left-facing arrows ◀️ . See original screenshots/report.

Code that triggers this appears to be clearLine()

CUI = "\033[" // Control Sequence Introducer

Best thing right now is either ignore it or use rage. I tried using mintty/cash and age does NOT work at under that (just hangs), rage works but uses GUI pinentry for password. You can use mintty/cmd, that does work and does avoid garbage control characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants