cli/command: PromptUserForCredentials: always trim password

we don't support empty passwords; when prompting the user for a password,
we already trim the result, but we didn't do the same for a password that's
passed through stdin or through the `-p` / `--password` flag.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a21a5f4243)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2024-10-19 12:10:46 +02:00
parent 78dbcca264
commit 1377310110
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 1 additions and 0 deletions

View File

@ -157,6 +157,7 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
} }
} }
argPassword = strings.TrimSpace(argPassword)
if argPassword == "" { if argPassword == "" {
restoreInput, err := DisableInputEcho(cli.In()) restoreInput, err := DisableInputEcho(cli.In())
if err != nil { if err != nil {