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 4a36b24
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/commands/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ impl Login {
let mut buf = String::new();
let mut stdin = std::io::stdin().lock();
stdin.read_to_string(&mut buf)?;
buf
// trim trailing newlines and carriage returns (see https://blog.v-gar.de/2019/04/rust-remove-trailing-newline-after-input)
buf.trim_end_matches(&['\r', '\n'][..]).to_owned()
} else {
match self.password {
Some(p) => p,
Expand Down

0 comments on commit 4a36b24

Please sign in to comment.