Skip to content

Conversation

nixxo
Copy link
Contributor

@nixxo nixxo commented Sep 4, 2025

Hello Rust community.
This is my first contribution, hope is useful.

While translating in Italian the rust book https://github.com/nixxo/rust-lang-book-it I noticed that the linkchecker tool was failing reporting broken links on some pages even if the link worked properly in the browser. Upon inspection I noticed that mdbook basically urlencoded the links, but not urlencoded the heading IDs resulting in a non-identical anchor/IDs pairing that linkchecker reports as non-valid.

looking at the source code for the linkchecker tool I noticed that urlencoding was done by the small_url_encode function in a partial way, as the name suggests. Replacing this function with a full urlencoding fixes the issue and the links are properly reported as valid.

  • added full urlencoding to properly check urlencoded anchor links against non-urlencoded heading IDs
  • added tests

urlecoding provided by https://crates.io/crates/urlencoding

@rustbot
Copy link
Collaborator

rustbot commented Sep 4, 2025

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ehuss
Copy link
Contributor

ehuss commented Sep 4, 2025

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 4, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 4, 2025
@ehuss
Copy link
Contributor

ehuss commented Sep 4, 2025

Let me know if you need help with the errors.

@nixxo
Copy link
Contributor Author

nixxo commented Sep 5, 2025

The error is about the Cargo.lock

error: the lock file /checkout/Cargo.lock needs to be updated but --locked was passed to prevent this If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.

So, I tried committing the cargo.lock file of the linkchecker package as well, but the problem persisted.

So, do I need to update the Cargo.lock file at the root of the repo?

@rustbot
Copy link
Collaborator

rustbot commented Sep 5, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@nixxo
Copy link
Contributor Author

nixxo commented Sep 7, 2025

@ehuss Ups, sorry. I noticed that after the committed fixes I didn't message you.

- added full urlencoding to properly check urlencoded anchor links against non-urlencoded heading IDs
- added tests

urlecoding provided by https://crates.io/crates/urlencoding
@ehuss
Copy link
Contributor

ehuss commented Sep 8, 2025

Thanks! I squashed the commits just to keep the history a little cleaner.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 8, 2025

📌 Commit 8b58777 has been approved by ehuss

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 8, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 8, 2025
fix partial urlencoded link support

Hello Rust community.
This is my first contribution, hope is useful.

While translating in Italian the rust book https://github.com/nixxo/rust-lang-book-it I noticed that the linkchecker tool was failing reporting broken links on some pages even if the link worked properly in the browser. Upon inspection I noticed that mdbook basically urlencoded the links, but not urlencoded the heading IDs resulting in a non-identical anchor/IDs pairing that linkchecker reports as non-valid.

looking at the source code for the linkchecker tool I noticed that urlencoding was done by the `small_url_encode` function in a partial way, as the name suggests. Replacing this function with a full urlencoding fixes the issue and the links are properly reported as valid.

- added full urlencoding to properly check urlencoded anchor links against non-urlencoded heading IDs
- added tests

urlecoding provided by https://crates.io/crates/urlencoding
bors added a commit that referenced this pull request Sep 8, 2025
Rollup of 11 pull requests

Successful merges:

 - #145177 (std: move `thread` into `sys`)
 - #146018 (compiler: Add Windows resources to rustc-main and rustc_driver)
 - #146025 (compiler: Include span of too huge array with `-Cdebuginfo=2`)
 - #146184 (In the rustc_llvm build script, don't consider arm64* to be 32-bit)
 - #146195 (fix partial urlencoded link support)
 - #146300 (Implement `Sum` and `Product` for `f16` and `f128`.)
 - #146314 (mark `format_args_nl!` as `#[doc(hidden)]`)
 - #146324 (const-eval: disable pointer fragment support)
 - #146326 (simplify the declaration of the legacy integer modules (`std::u32` etc.))
 - #146339 (Update books)
 - #146343 (Weakly export `platform_version` symbols)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 9, 2025
fix partial urlencoded link support

Hello Rust community.
This is my first contribution, hope is useful.

While translating in Italian the rust book https://github.com/nixxo/rust-lang-book-it I noticed that the linkchecker tool was failing reporting broken links on some pages even if the link worked properly in the browser. Upon inspection I noticed that mdbook basically urlencoded the links, but not urlencoded the heading IDs resulting in a non-identical anchor/IDs pairing that linkchecker reports as non-valid.

looking at the source code for the linkchecker tool I noticed that urlencoding was done by the `small_url_encode` function in a partial way, as the name suggests. Replacing this function with a full urlencoding fixes the issue and the links are properly reported as valid.

- added full urlencoding to properly check urlencoded anchor links against non-urlencoded heading IDs
- added tests

urlecoding provided by https://crates.io/crates/urlencoding
bors added a commit that referenced this pull request Sep 9, 2025
Rollup of 11 pull requests

Successful merges:

 - #139593 (add sitemap to rust docs)
 - #145819 (Port limit attributes to the new attribute parsing infrastructure)
 - #146025 (compiler: Include span of too huge array with `-Cdebuginfo=2`)
 - #146184 (In the rustc_llvm build script, don't consider arm64* to be 32-bit)
 - #146195 (fix partial urlencoded link support)
 - #146300 (Implement `Sum` and `Product` for `f16` and `f128`.)
 - #146314 (mark `format_args_nl!` as `#[doc(hidden)]`)
 - #146324 (const-eval: disable pointer fragment support)
 - #146326 (simplify the declaration of the legacy integer modules (`std::u32` etc.))
 - #146339 (Update books)
 - #146343 (Weakly export `platform_version` symbols)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Sep 9, 2025
Rollup of 11 pull requests

Successful merges:

 - #139593 (add sitemap to rust docs)
 - #145819 (Port limit attributes to the new attribute parsing infrastructure)
 - #146025 (compiler: Include span of too huge array with `-Cdebuginfo=2`)
 - #146184 (In the rustc_llvm build script, don't consider arm64* to be 32-bit)
 - #146195 (fix partial urlencoded link support)
 - #146300 (Implement `Sum` and `Product` for `f16` and `f128`.)
 - #146314 (mark `format_args_nl!` as `#[doc(hidden)]`)
 - #146324 (const-eval: disable pointer fragment support)
 - #146326 (simplify the declaration of the legacy integer modules (`std::u32` etc.))
 - #146339 (Update books)
 - #146343 (Weakly export `platform_version` symbols)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3bd603b into rust-lang:master Sep 9, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Sep 9, 2025
rust-timer added a commit that referenced this pull request Sep 9, 2025
Rollup merge of #146195 - nixxo:urlencoding-fix, r=ehuss

fix partial urlencoded link support

Hello Rust community.
This is my first contribution, hope is useful.

While translating in Italian the rust book https://github.com/nixxo/rust-lang-book-it I noticed that the linkchecker tool was failing reporting broken links on some pages even if the link worked properly in the browser. Upon inspection I noticed that mdbook basically urlencoded the links, but not urlencoded the heading IDs resulting in a non-identical anchor/IDs pairing that linkchecker reports as non-valid.

looking at the source code for the linkchecker tool I noticed that urlencoding was done by the `small_url_encode` function in a partial way, as the name suggests. Replacing this function with a full urlencoding fixes the issue and the links are properly reported as valid.

- added full urlencoding to properly check urlencoded anchor links against non-urlencoded heading IDs
- added tests

urlecoding provided by https://crates.io/crates/urlencoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants