Customize: Sanitize autofocus URL parameter as an array.

[58069] introduced calling `sanitize_text_field()` with `$_REQUEST['autofocus']` (which is an array) and setting its default to a `string`. This fix restores the `array` data type for `autofocus`.

The fix also relocates the unsplash for `url`, `return`, and `autofocus` before sanitizing.

Follow-up to [58069], [34269], [29026], [21028].

Props jamesros161, swissspidy, dlh, audrasjb, hellofromTonya, ironprogrammer.
Fixes #61561.
Built from https://develop.svn.wordpress.org/trunk@58804


git-svn-id: http://core.svn.wordpress.org/trunk@58200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2024-07-24 16:23:17 +00:00
parent 0702cafa87
commit 7c1295fdb9
2 changed files with 10 additions and 8 deletions

View File

@ -84,18 +84,20 @@ if ( $wp_customize->changeset_post_id() ) {
} }
} }
$url = ! empty( $_REQUEST['url'] ) ? sanitize_text_field( $_REQUEST['url'] ) : ''; $url = ! empty( $_REQUEST['url'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['url'] ) ) : '';
$return = ! empty( $_REQUEST['return'] ) ? sanitize_text_field( $_REQUEST['return'] ) : ''; $return = ! empty( $_REQUEST['return'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['return'] ) ) : '';
$autofocus = ! empty( $_REQUEST['autofocus'] ) ? sanitize_text_field( $_REQUEST['autofocus'] ) : ''; $autofocus = ! empty( $_REQUEST['autofocus'] ) && is_array( $_REQUEST['autofocus'] )
? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['autofocus'] ) )
: array();
if ( ! empty( $url ) ) { if ( ! empty( $url ) ) {
$wp_customize->set_preview_url( wp_unslash( $url ) ); $wp_customize->set_preview_url( $url );
} }
if ( ! empty( $return ) ) { if ( ! empty( $return ) ) {
$wp_customize->set_return_url( wp_unslash( $return ) ); $wp_customize->set_return_url( $return );
} }
if ( ! empty( $autofocus ) && is_array( $autofocus ) ) { if ( ! empty( $autofocus ) ) {
$wp_customize->set_autofocus( wp_unslash( $autofocus ) ); $wp_customize->set_autofocus( $autofocus );
} }
$registered = $wp_scripts->registered; $registered = $wp_scripts->registered;

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.7-alpha-58803'; $wp_version = '6.7-alpha-58804';
/** /**
* 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.