Skip to content

fix: detect redirect loops during HTML build#3104

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

fix: detect redirect loops during HTML build#3104
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:fix/redirect-loop-detection-2901-v2

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Fixes #2901.

Detects cycles in [output.html.redirect] at build time and fails with a clear error, instead of letting the browser reload redirect pages indefinitely.

Changes

  • Walk redirect entries to find cycles (including fragment redirects like /page.html#frag)
  • Report a canonical cycle path in the error message
  • Unit and integration tests for page-level and fragment-level loops

Test plan

  • cargo test -p mdbook-html redirect_loop
  • cargo test redirect_loop (testsuite)
  • CI

Made with Cursor

Validate `[output.html.redirect]` for cycles before emitting redirect
pages, so misconfigured loops fail at build time instead of reloading
in the browser indefinitely. 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
@leno23
Copy link
Copy Markdown
Author

leno23 commented May 17, 2026

Closing as duplicate of #3103 (same fix for #2901). Keeping #3103 for review.

@leno23 leno23 closed this May 17, 2026
@rustbot rustbot removed 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redirects should have loop detection

2 participants