diff --git a/src/commands/registry.rs b/src/commands/registry.rs index ddf99afcd3..a78fbd1d05 100644 --- a/src/commands/registry.rs +++ b/src/commands/registry.rs @@ -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 {