[wp-trac] [WordPress Trac] #44759: percent encoded unicode characters in post type rewrite slug
WordPress Trac
noreply at wordpress.org
Wed Aug 8 18:03:23 UTC 2018
#44759: percent encoded unicode characters in post type rewrite slug
-------------------------------+-----------------------------
Reporter: mnelson4 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
If you register a custom post type whose rewrite slug has percent-encoded
unicode characters in it, the posts can't be found on the front-end.
Eg
{{{#!php
<?php
function register_unicode_cpt()
{
register_post_type(
'unicode_cpt',
array(
'label' => 'unicode-cpts',
'public' => true,
'rewrite' => array(
'slug' => '%E6%BC%A2%E8%AA%9E%3B' // doesn't work
// 'rewrite_slug' => '漢語' // works
)
)
);
}
add_action('init','register_unicode_cpt');
}}}
Seems to initially work fine, the ugly percent-encoded unicode characters
don't appear in the post editor (Eg
https://drive.google.com/a/eventespresso.com/file/d/1d1j6skbgxrA7IJocGvYi5UMQ_Xw3sCrV/view?usp=drivesdk),
but when I go to view the CPT, I'm being redirected to the homepage, (or,
when my homepage displays latest posts, I'm seeing those without being
redirected).
It seems some code needs to recognize percent-encoded rewrite slugs are
the same as the unicode character ones.
The workaround is to use the unicode characters directly, which is
technically against the RFC (see
https://stackoverflow.com/questions/2742852/unicode-characters-in-
urls/2742985#2742985)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44759>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list