From cc7e4357b2f3318b60ef96abeb372f250cdc1503 Mon Sep 17 00:00:00 2001 From: joedolson Date: Tue, 3 Sep 2024 16:41:13 +0000 Subject: [PATCH] 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 unslash for url, return, and autofocus before sanitizing. Follow-up to [58069], [34269], [29026], [21028]. Reviewed by joedolson. Merges [58804] to the 6.6 branch. Props jamesros161, swissspidy, dlh, audrasjb, hellofromTonya, ironprogrammer, debarghyabanerjee. Fixes #61561. Built from https://develop.svn.wordpress.org/branches/6.6@58973 git-svn-id: http://core.svn.wordpress.org/branches/6.6@58369 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/customize.php | 16 +++++++++------- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/wp-admin/customize.php b/wp-admin/customize.php index 2a53480fee..40857031a7 100644 --- a/wp-admin/customize.php +++ b/wp-admin/customize.php @@ -84,18 +84,20 @@ if ( $wp_customize->changeset_post_id() ) { } } -$url = ! empty( $_REQUEST['url'] ) ? sanitize_text_field( $_REQUEST['url'] ) : ''; -$return = ! empty( $_REQUEST['return'] ) ? sanitize_text_field( $_REQUEST['return'] ) : ''; -$autofocus = ! empty( $_REQUEST['autofocus'] ) ? sanitize_text_field( $_REQUEST['autofocus'] ) : ''; +$url = ! empty( $_REQUEST['url'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['url'] ) ) : ''; +$return = ! empty( $_REQUEST['return'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['return'] ) ) : ''; +$autofocus = ! empty( $_REQUEST['autofocus'] ) && is_array( $_REQUEST['autofocus'] ) + ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['autofocus'] ) ) + : array(); if ( ! empty( $url ) ) { - $wp_customize->set_preview_url( wp_unslash( $url ) ); + $wp_customize->set_preview_url( $url ); } if ( ! empty( $return ) ) { - $wp_customize->set_return_url( wp_unslash( $return ) ); + $wp_customize->set_return_url( $return ); } -if ( ! empty( $autofocus ) && is_array( $autofocus ) ) { - $wp_customize->set_autofocus( wp_unslash( $autofocus ) ); +if ( ! empty( $autofocus ) ) { + $wp_customize->set_autofocus( $autofocus ); } $registered = $wp_scripts->registered; diff --git a/wp-includes/version.php b/wp-includes/version.php index 2540341cf4..bb0ebed5f6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6.2-alpha-58916'; +$wp_version = '6.6.2-alpha-58973'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.