Make WordPress Core

Opened 7 years ago

Last modified 7 years ago

#41791 new defect (bug)

Unicode + add_permastruct breaks rewrite rules

Reported by: mikejolley's profile 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:

Description

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:

https://www.dropbox.com/s/5vztnfm6895488a/query%20is%20wrong.png?dl=0

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

https://www.dropbox.com/s/24zyr5v7taw7b60/correct.png?dl=0

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 7 years ago.
Fix for 41791
41791.diff (436 bytes) - added by Soean 7 years ago.
Added a closing parenthes.

Download all attachments as: .zip

Change History (5)

@mikejolley
7 years ago

Fix for 41791

#1 @mikejolley
7 years ago

  • Keywords has-patch dev-feedback added

#2 @SergeyBiryukov
7 years ago

  • Keywords needs-unit-tests added

@Soean
7 years ago

Added a closing parenthes.

Note: See TracTickets for help on using tickets.