Make WordPress Core

Changeset 58804


Ignore:
Timestamp:
07/24/2024 04:21:59 PM (8 months ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/customize.php

    r58069 r58804  
    8585}
    8686
    87 $url       = ! empty( $_REQUEST['url'] ) ? sanitize_text_field( $_REQUEST['url'] ) : '';
    88 $return    = ! empty( $_REQUEST['return'] ) ? sanitize_text_field( $_REQUEST['return'] ) : '';
    89 $autofocus = ! empty( $_REQUEST['autofocus'] ) ? sanitize_text_field( $_REQUEST['autofocus'] ) : '';
     87$url       = ! empty( $_REQUEST['url'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['url'] ) ) : '';
     88$return    = ! empty( $_REQUEST['return'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['return'] ) ) : '';
     89$autofocus = ! empty( $_REQUEST['autofocus'] ) && is_array( $_REQUEST['autofocus'] )
     90    ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['autofocus'] ) )
     91    : array();
    9092
    9193if ( ! empty( $url ) ) {
    92     $wp_customize->set_preview_url( wp_unslash( $url ) );
     94    $wp_customize->set_preview_url( $url );
    9395}
    9496if ( ! empty( $return ) ) {
    95     $wp_customize->set_return_url( wp_unslash( $return ) );
    96 }
    97 if ( ! empty( $autofocus ) && is_array( $autofocus ) ) {
    98     $wp_customize->set_autofocus( wp_unslash( $autofocus ) );
     97    $wp_customize->set_return_url( $return );
     98}
     99if ( ! empty( $autofocus ) ) {
     100    $wp_customize->set_autofocus( $autofocus );
    99101}
    100102
Note: See TracChangeset for help on using the changeset viewer.