fix(credential): trim newlines in tokens from stdin#13770
fix(credential): trim newlines in tokens from stdin#13770bors merged 2 commits intorust-lang:masterfrom
Conversation
|
I know this is unlikely but is there any case where newlines could be significant to these tokens? |
The token is directly sent as the If you try to use it, you get: |
| .with_stderr( | ||
| "\ | ||
| [UPDATING] crates.io index | ||
| please paste the token found on [..] below |
There was a problem hiding this comment.
How is this test passing today?
There was a problem hiding this comment.
In the read_token function, if a token is provided by stdin or by the command line, then no prompt is made.
The change causes login_options.token to be None, instead of a Some("\n"), so Cargo now prints the "please paste" message in this case.
cargo/credential/cargo-credential/src/lib.rs
Lines 281 to 290 in 852a316
There was a problem hiding this comment.
Could you move that change into the commit that caused it so that each commit passes tests?
There was a problem hiding this comment.
Fixed. I should have amended that instead of adding a commit.
118e45e to
6207f93
Compare
|
@bors r+ |
|
☀️ Test successful - checks-actions |
Update cargo 8 commits in 6f06fe908a5ee0f415c187f868ea627e82efe07d..80d5b607dde6ef97dfff4e23923822c01d2bb036 2024-04-16 18:47:44 +0000 to 2024-04-19 18:39:22 +0000 - fix 13773 - 'cargo build' fails when list_files() with gix is triggered (rust-lang/cargo#13777) - fix(toml): Don't crash on parse errors that point to multi-byte character (rust-lang/cargo#13780) - fix(toml)!: Disallow source-less dependencies (rust-lang/cargo#13775) - fix(msrv): Put MSRV-aware resolver behind a config (rust-lang/cargo#13769) - fix(msrv): Error, rather than panic, on rust-version 'x' (rust-lang/cargo#13771) - fix(credential): trim newlines in tokens from stdin (rust-lang/cargo#13770) - test(msrv): Re-organize MSRV tests (rust-lang/cargo#13767) - feat(install): Including Locking message (rust-lang/cargo#13764) r? ghost
Update cargo 8 commits in 6f06fe908a5ee0f415c187f868ea627e82efe07d..80d5b607dde6ef97dfff4e23923822c01d2bb036 2024-04-16 18:47:44 +0000 to 2024-04-19 18:39:22 +0000 - fix 13773 - 'cargo build' fails when list_files() with gix is triggered (rust-lang/cargo#13777) - fix(toml): Don't crash on parse errors that point to multi-byte character (rust-lang/cargo#13780) - fix(toml)!: Disallow source-less dependencies (rust-lang/cargo#13775) - fix(msrv): Put MSRV-aware resolver behind a config (rust-lang/cargo#13769) - fix(msrv): Error, rather than panic, on rust-version 'x' (rust-lang/cargo#13771) - fix(credential): trim newlines in tokens from stdin (rust-lang/cargo#13770) - test(msrv): Re-organize MSRV tests (rust-lang/cargo#13767) - feat(install): Including Locking message (rust-lang/cargo#13764) r? ghost
Update cargo 8 commits in 6f06fe908a5ee0f415c187f868ea627e82efe07d..80d5b607dde6ef97dfff4e23923822c01d2bb036 2024-04-16 18:47:44 +0000 to 2024-04-19 18:39:22 +0000 - fix 13773 - 'cargo build' fails when list_files() with gix is triggered (rust-lang/cargo#13777) - fix(toml): Don't crash on parse errors that point to multi-byte character (rust-lang/cargo#13780) - fix(toml)!: Disallow source-less dependencies (rust-lang/cargo#13775) - fix(msrv): Put MSRV-aware resolver behind a config (rust-lang/cargo#13769) - fix(msrv): Error, rather than panic, on rust-version 'x' (rust-lang/cargo#13771) - fix(credential): trim newlines in tokens from stdin (rust-lang/cargo#13770) - test(msrv): Re-organize MSRV tests (rust-lang/cargo#13767) - feat(install): Including Locking message (rust-lang/cargo#13764) r? ghost
What does this PR try to resolve?
cargo loginwhen using a credential provider other thancargo:tokendoes not automatically trim whitespace from tokens.This can lead to extra whitespace being included in the pasted token value (usually a trailing newline) that makes the token invalid.
How should we test and review this PR?
First commit adds a test showing the problematic behavior. Second commit fixes it.