Tome + Redirect can introduce critical redirect issue

Created on 12 November 2020, over 4 years ago
Updated 22 January 2025, 2 months ago

Problem/Motivation

When Tome is used with the ubiquitous Redirect module a very nasty redirect situation can occur. This will only happen, though, if the HTML on a page references a page with a trailing slash.

Steps to reproduce

1) Install Drupal core.
2) Install Tome Static
3) Install Redirect
4) Create a Basic Page
5) Set the alias to /test
6) In the body area add a link with the href set to \test\ (trailing slash)
7) Run the Tome Static generator
8) Look at the resultant HTML and observe that the test/index.html file is a redirect.

This is happening because the /test page and the /test/ page are competing for the same index.html file. The static process runs and generates a correct page, it then parses that HTML and detects the reference to /test/ and tries to render that too. Drupal with Redirect will ensure that a canonical version of the page is output by issuing a redirect to /test. The problem, though, is Tome writes that redirect content over the file it generate during the first pass - ending up with a fatally broken static version.

Proposed resolution

Still not entirely sure. I think the best way to solve it is to strip trailing slashes before it processes the path. I am just slightly unsure if that will introduce any side-effect. I suspect and hope not.

Remaining tasks

Still unsure

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Tome Static

Created by

πŸ‡ΊπŸ‡ΈUnited States AndyThornton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • miiimooo Europe

    The latest patch works for me to fix this annoying problem. I think it might even be enough to have aliases for this problem.

    BUT, I had to disable the Enforce clean and canonical URLs in the redirect settings admin/config/search/redirect/settings

Production build 0.71.5 2024