Skip to content

Support percent-encoded chapter paths#3162

Open
ychampion wants to merge 1 commit into
rust-lang:masterfrom
ychampion:fix/percent-encoded-summary-paths
Open

Support percent-encoded chapter paths#3162
ychampion wants to merge 1 commit into
rust-lang:masterfrom
ychampion:fix/percent-encoded-summary-paths

Conversation

@ychampion

Copy link
Copy Markdown

Summary

  • decode percent-encoded chapter paths before reading source files
  • encode generated chapter URLs in navigation, TOC, redirects, and search output

Why

SUMMARY.md only decoded %20, so a path such as question%3F.md could not load question?.md. Emitting the decoded path unchanged would also turn ? and # filename characters into URL delimiters.

Closes #1640.

Validation

  • cargo test -p mdbook-summary -p mdbook-html — passed
  • cargo test --test testsuite toc::percent_encoded_chapter_paths -- --exact — passed
  • cargo test --test testsuite toc::percent_encoded_chapter_paths --no-default-features -- --exact — passed
  • cargo clippy --workspace --all-targets --no-deps -- -D warnings — passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --document-private-items --no-deps — passed
  • cargo fmt --all --check — passed

Decode valid UTF-8 escapes for source lookup, then encode generated chapter URL surfaces so path delimiters remain filename characters.

Constraint: Chapter filenames may contain URL delimiters that must be decoded for disk access and re-encoded in generated links.

Rejected: Decode without renderer encoding | would turn question marks and hashes into URL delimiters.

Confidence: high

Scope-risk: moderate

Directive: Keep filesystem paths decoded internally and encode only generated chapter URL surfaces.

Tested: summary/html crate suites with and without defaults; targeted TOC regression in both feature modes; workspace packages; 109/111 root tests; strict Clippy; rustdoc; rustfmt; guide build; CLI reproduction

Not-tested: Native Windows filesystem behavior for question-mark filenames; two nested-Cargo harness cases blocked by the external target location
@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please make SUMMARY.md support urlencode markdown file name

2 participants