mirror of https://github.com/rust-lang/cargo
fix(credential): trim newlines in token from stdin for credential providers
This commit is contained in:
parent
a498391686
commit
6207f93087
|
@ -39,7 +39,7 @@ pub fn registry_login(
|
|||
let mut token_from_stdin = None;
|
||||
let token = token_from_cmdline.or_else(|| {
|
||||
if !std::io::stdin().is_terminal() {
|
||||
let token = std::io::read_to_string(std::io::stdin()).unwrap_or_default();
|
||||
let token = cargo_credential::read_line().unwrap_or_default();
|
||||
if !token.is_empty() {
|
||||
token_from_stdin = Some(token);
|
||||
}
|
||||
|
|
|
@ -709,7 +709,7 @@ fn login_token_from_stdin() {
|
|||
.with_stdin("abcdefg\n")
|
||||
.with_stderr(
|
||||
r#"[UPDATING] [..]
|
||||
{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg\n","login-url":"[..]"}
|
||||
{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]"}
|
||||
"#,
|
||||
)
|
||||
.run();
|
||||
|
|
|
@ -113,6 +113,7 @@ fn empty_login_token() {
|
|||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] crates.io index
|
||||
please paste the token found on [..] below
|
||||
[ERROR] credential provider `cargo:token` failed action `login`
|
||||
|
||||
Caused by:
|
||||
|
|
Loading…
Reference in New Issue