Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #11600 - Akida31:issue-11571-bad-token, r=Eh2406
Error on invalid alphanumeric token for crates.io ref #11571 When using `cargo login` and calling an api which requires authentification there will be an error if the given token is not a valid alphanumerical string. This check is only enabled for crates.io because only for that registry we can be certain, that the generated token should have been alphanumeric, see [the code here](https://github.com/rust-lang/crates.io/blob/7ea41e9d345f05566ee776b7cbb62e46ccf6b393/src/util/token.rs#L15). So if I'm not mistaken, this should not be a breaking change, since crates.io only generates fitting tokens. (Should I add a comment to the crates.io code that modifying this logic can break cargo?) I'm not sure if the fix works and is enough to close the issue, please say if you have any corrections or improvements! I don't know if the check should also be enabled for other registries and it would be really bad if the check is too strict. In the linked issue it was recommended to encode invalid characters, but I don't know in which encoding. I saw in [this http rfc](https://www.rfc-editor.org/rfc/rfc7230#section-3.2.4) that only the ISO-8859-1 charset is allowed and everything else must be [encoded](https://www.rfc-editor.org/rfc/rfc7230#section-3.2.4) but this seems somewhat complex and hard to implement. There is a crate `rust-encoding` which should be capable doing this (from a first look), but I don't know if a new dependency only for this is justified. There seems to be `percent encoding` already in the dependency tree but I have no idea if it would be correct and work. If you have any idea about this encoding, please say so. r? `@Eh2406` (since you suggested the encoding part)
- Loading branch information