Skip to content

fix(html): detect redirect loops at build time#3103

Open
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:fix/redirect-loop-detection-2901
Open

fix(html): detect redirect loops at build time#3103
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:fix/redirect-loop-detection-2901

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Detects cycles in [output.html.redirect] during the HTML build and fails with a clear error instead of generating redirect pages that reload indefinitely in the browser.

Example error:

redirect loop detected: /chapter_1.html#a -> chapter_2.html#b -> /chapter_2.html#b -> chapter_1.html#a

External destinations (http://, https://, //) terminate the chain and are not treated as redirect sources.

Fixes #2901.

Test plan

  • Added redirects/redirect_loop testsuite case
  • cargo test -p mdbook --test testsuite (111 passed)

Made with Cursor

Reject `[output.html.redirect]` configurations that form a cycle
before emitting redirect pages, with an error message showing the loop.

Fixes rust-lang#2901.

Co-authored-by: Cursor <cursoragent@cursor.com>
@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label May 17, 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.

Redirects should have loop detection

2 participants