Skip to content

Commit

Permalink
fix: strip newline and carriage return when password is read from stdin
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Beck <[email protected]>
  • Loading branch information
nico1510 committed Feb 22, 2023
1 parent 3da388c commit 526b32d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/commands/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ impl Login {
let mut buf = String::new();
let mut stdin = std::io::stdin().lock();
stdin.read_to_string(&mut buf)?;
// trim trailing newlines and carriage returns (see https://blog.v-gar.de/2019/04/rust-remove-trailing-newline-after-input)
let len = buf.trim_end_matches(&['\r', '\n'][..]).len();
buf.truncate(len);
buf
} else {
match self.password {
Expand Down

0 comments on commit 526b32d

Please sign in to comment.