REST API: Support non-Latin characters in template route regex.

Non-Latin characters are URL-encoded (e.g. `%cf%84%ce%b5%cf%83%cf%84`). Matching `%` in the route ensures templates with non-Latin titles can be properly saved.

Props antonyagrios, mburridge.
Fixes #57329.

Built from https://develop.svn.wordpress.org/trunk@55294


git-svn-id: http://core.svn.wordpress.org/trunk@54827 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
danielbachhuber 2023-02-07 23:47:23 +00:00
parent 270a3d009d
commit e41af7cdc6
2 changed files with 3 additions and 3 deletions

View File

@ -105,7 +105,7 @@ class WP_REST_Templates_Controller extends WP_REST_Controller {
// Excludes invalid directory name characters: `/:<>*?"|`. // Excludes invalid directory name characters: `/:<>*?"|`.
'([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)', '([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)',
// Matches the template name. // Matches the template name.
'[\/\w-]+' '[\/\w%-]+'
), ),
array( array(
'args' => array( 'args' => array(
@ -834,7 +834,7 @@ class WP_REST_Templates_Controller extends WP_REST_Controller {
'context' => array( 'embed', 'view', 'edit' ), 'context' => array( 'embed', 'view', 'edit' ),
'required' => true, 'required' => true,
'minLength' => 1, 'minLength' => 1,
'pattern' => '[a-zA-Z0-9_\-]+', 'pattern' => '[a-zA-Z0-9_\%-]+',
), ),
'theme' => array( 'theme' => array(
'description' => __( 'Theme identifier for the template.' ), 'description' => __( 'Theme identifier for the template.' ),

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.2-beta1-55293'; $wp_version = '6.2-beta1-55294';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.