Skip to content

Infinite redirect warning when URL pattern contains encoded # (%23) #218

@brandonkelly

Description

@brandonkelly

Describe the bug

Just experienced a weird bug with the Twitter Mac app, where a URL with a hash in it (https://craftcms.com/knowledge-base/configuring-load-balanced-environments#mutex-locks) was getting its hash mark encoded to %23:

https://craftcms.com/knowledge-base/configuring-load-balanced-environments%23mutex-locks

I figured it would be easy enough to add a redirect for that in Retour, however Retour ended up decoding the %23 to #, and then didn’t like how the redirect URL looked identical to the URL pattern, saying it would create an infinite redirect loop.

I ended up working around it by setting the Match Type to regex, and the URL pattern to:

/knowledge-base/configuring-load-balanced-environments.+mutex-locks

Ideally Retour would not be decoding the %23 – if that’s even possible? – and also should not be rejecting matching URL patterns/destination URLs if the pattern contains a #, since the hash would never get sent to the server in the first place.

To reproduce

  1. Go to Retour → Redirects and create a new redirect
  2. Enter /foo%23bar as the URL pattern
  3. Enter /foo#bar as the destination URL
  4. Press Save

Expected behaviour

The redirect should save, with the URL pattern unmodified, and no warnings about redirect loops.

Versions

  • Plugin version: 3.1.69
  • Craft version: 3.7.27

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions