Skip to content

Redirects should have loop detection #2901

@ehuss

Description

@ehuss

Problem

If a redirect chain ends in a loop, the browser will reload the pages indefinitely.

Steps

Set up a redirect loop, such as the following:

[output.html.redirect]
"/chapter_1.html#a" = "chapter_2.html#b"
"/chapter_2.html#b" = "chapter_1.html#a"

with a SUMMARY.md:

# Summary

- [Chapter 1](./chapter_1.md)
- [Chapter 2](./chapter_2.md)

Navigate to chapter_1.html#a

Possible Solution(s)

I'm not sure exactly what should be done. One thing to consider is that loops can happen in between books. Some ideas:

  • During book building, detect a loop and report an error.
  • When redirecting, use some mechanism to track the number of redirects. I don't know what this would look like, but url query parameters, cookies, or localstorage are some potential options. It looks like browsers allow roughly 20 redirects (when using http redirects).

Notes

No response

Version

mdbook v0.5.0-alpha.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-redirectArea: the HTML redirect tableC-bugCategory: A bug, incorrect or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions