WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 4 weeks ago

#52376 new defect (bug)

Redirect loop occurs in taxonomy archive with URL-encoded slug.

Reported by: Toro_Unit Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Canonical Keywords: has-patch needs-testing
Focuses: Cc:

Description

The following steps will occur.

  1. Create taxonomy with rewrite => false.
<?php
        $args = array(
                'label'            => 'Genre',
                'public'           => true,
                'rewrite'           => false,
        );

        register_taxonomy( 'genre', array( 'post' ), $args );
  1. Create a term with URL-encoded slugs. ( example: 🏠, ワードプレス )
  2. Set Permalink structure to to something other than Plain.
  3. Go to the archive of the created term.
  4. Redirect loop.

remove_action( 'template_redirect', 'redirect_canonical' ), it will not occur.

Change History (2)

This ticket was mentioned in ​PR #956 on ​WordPress/wordpress-develop by ​donmhico.


4 weeks ago

  • Keywords has-patch added; needs-patch removed

The issue is $redirect['query'] and $original['query'] are never equal because it's comparing the urlencoded vs non urlencoded version.

For example

$original['query'] = 'genre=%e3%83%af%e3%83%bc%e3%83%89%e3%83%97%e3%83%ac%e3%82%b9'
$redirect['query'] = 'genre=ワードプレス'

Basically the _value_ of _genre_ are the same, urlencoded-wise.

We still use the same logic as the previous $compare_original !== $compare_redirect, we just changed it so that we can handle the query difference.

This still needs more eyes and testing.

Trac ticket: https://core.trac.wordpress.org/ticket/52376

#2 @donmhico
4 weeks ago

  • Keywords needs-testing added

The PR above is a potential fix for this issue. It still needs more testing.

Note: See TracTickets for help on using tickets.