natemcmaster / CommandLineUtils

Command line parsing and utilities for .NET

Home Page:https://natemcmaster.github.io/CommandLineUtils/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GetPassword is broken

ZacharyPatten opened this issue · comments

GetPassword is broken

  1. Writing "\b \b" will not move up lines in the console, so if the input currently spans multiple lines your backspace breaks (will not back space to previous lines in the console).
  2. It doesn't support Delete, Left/Right Arrow, Home, or End. Or the CTRL modifier.
  3. When pressing keys such as those mentioned in 2. and keys like F1 through F12 it is adding '\0' chars to the resulting string.
  4. The display character should be an optional parameter so the user can choose alternatives to the hard coded '*' character.
  5. Why have ConsoleColor parameters or a prompt on the method? Let other code handle that.
  6. The SecureString is obsolete in .NET Core, so you should probably not include that in packages that target frameworks other than .NET Framework.

Example fixes

I have written my own version of this method that fixes topics1.-5. from above:
Source Code
Example Code

Also, I mentioned that topic 5. from above should be handled by other means than optional parameters on every relevant method; here is an example of a better approach in my opinion:
Source Code
There are example usages in the same file as the source code.

It seems you know what needs to be fixed. Would you mind raising a pull request?

Re:

The SecureString is obsolete in .NET Core, so you should probably not include that in packages that target frameworks other than .NET Framework.

I'd rather keep the API until .NET actually deprecates. I know there has been discussion about doing so, but as of .NET 5 this API is still not officially marked as [Obsolete].

Sorry for the late response, yes I do know the fix (the example I linked fixes it). But it is a different approach and I would recommend someone test both approaches to see if there are any negatives of my approach in comparison. Although my version fixes this issue, I'm not sure if it introduces any other issues.

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please comment if you believe this should remain open, otherwise it will be closed in 14 days. Thank you for your contributions to this project.

Closing due to inactivity.
If you are looking at this issue in the future and think it should be reopened, please make a commented here and mention natemcmaster so he sees the notification.

I noticed that a bot closed this, but this is still an open/active issue.

I don't use your library so I haven't been motivated to open a pull request, but all the info on how to fix it was provided for someone willing.

My stance on this is here #485. I can reopen the issue, but the bot will just close again in a year if no one comes forward to implement a fix.

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please comment if you believe this should remain open, otherwise it will be closed in 14 days. Thank you for your contributions to this project.

Closing due to inactivity.
If you are looking at this issue in the future and think it should be reopened, please make a commented here and mention natemcmaster so he sees the notification.