Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#52376 new defect (bug)

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

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


The following steps will occur.

  1. Create taxonomy with rewrite => false.
        $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.

3 years 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:

#2 @donmhico
3 years 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.