Skip to content

Commit 4537f2f

Browse files
committed
fix: strip newline and carriage return when password is read from stdin
Signed-off-by: Nico Beck <[email protected]>
1 parent 5a70007 commit 4537f2f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/commands/registry.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ impl Login {
143143
let mut buf = String::new();
144144
let mut stdin = std::io::stdin().lock();
145145
stdin.read_to_string(&mut buf)?;
146-
buf
146+
// trim trailing newlines and carriage returns (see https://blog.v-gar.de/2019/04/rust-remove-trailing-newline-after-input)
147+
buf.trim_end_matches(&['\r', '\n'][..]).to_owned()
147148
} else {
148149
match self.password {
149150
Some(p) => p,

0 commit comments

Comments
 (0)