Skip to content

[rustdoc] Wrong URL encoding for % sign #112580

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
TumoiYorozu opened this issue Jun 13, 2023 · 0 comments · Fixed by #112581
Closed

[rustdoc] Wrong URL encoding for % sign #112580

TumoiYorozu opened this issue Jun 13, 2023 · 0 comments · Fixed by #112581
Labels
regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@TumoiYorozu
Copy link
Contributor

The source code in the Rust Documentation can be executed using the Rust Playground by pressing the "Run" button, but the URL encoding of the % symbol used is incorrect and will not execute correctly.

The % is encoded as %%, but the correct encoding is %25.

For example, Vec retain has source code containing %.

let mut vec = vec![1, 2, 3, 4];
vec.retain(|&x| x % 2 == 0);
assert_eq!(vec, [2, 4]);

https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.retain

This "Run" is linked to the following
https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0Alet+mut+vec+=+vec!%5B1,+2,+3,+4%5D;%0Avec.retain(%7C%26x%7C+x+%%+2+==+0);%0Aassert_eq!(vec,+%5B2,+4%5D);%0A%7D&edition=2021

However, this does not work correctly. The correct way is as follows.
https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0Alet+mut+vec+=+vec!%5B1,+2,+3,+4%5D;%0Avec.retain(%7C%26x%7C+x+%25+2+==+0);%0Aassert_eq!(vec,+%5B2,+4%5D);%0A%7D&edition=2021

@notriddle notriddle added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jun 13, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 13, 2023
@notriddle notriddle added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jun 13, 2023
@bors bors closed this as completed in 623b1d4 Jun 14, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants