Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#41791 new defect (bug)

Unicode + add_permastruct breaks rewrite rules

Reported by: mikejolley Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9
Component: Rewrite Rules Keywords: has-patch dev-feedback needs-unit-tests
Focuses: Cc:


This was reported here https://github.com/woocommerce/woocommerce/issues/16673

To recreate the issue, create a taxonomy with a cyrillic name such as Сертификат. View the taxonomy archive. You'll see no results; it will go to the homepage rather than an archive.

In WooCommerce you can recreate this by creating an attribute (Product > Attributes) with a cyrillic name, and enabling the 'archive', assigning a term from this taxonomy to a product, and trying to view products by that term.

I managed to trace it back to the add_permastruct. The struct is added with unicode % encoded characters. When the rewrite rules are processed, it thinks these are placeholders so the matches variables do not align. See this screenshot for clarity:


Notice all the $matches? Compare to a working taxonomy:


This can be fixed by using urldecode when adding the permastruct. I don't know if this has side effects but it worked in testing.

Patch to follow.

Attachments (2)

fix.41791.diff (436 bytes) - added by mikejolley 4 years ago.
Fix for 41791
41791.diff (436 bytes) - added by Soean 4 years ago.
Added a closing parenthes.

Download all attachments as: .zip

Change History (5)

4 years ago

Fix for 41791

#1 @mikejolley
4 years ago

  • Keywords has-patch dev-feedback added

#2 @SergeyBiryukov
4 years ago

  • Keywords needs-unit-tests added

4 years ago

Added a closing parenthes.

Note: See TracTickets for help on using tickets.