Make WordPress Core

Changeset 58973 for branches/6.6

Timestamp:
09/03/2024 04:39:29 PM (2 weeks ago)
Author:
joedolson
Message:

Customize: Sanitize autofocus URL parameter as an array.

[58069] introduced calling sanitize_text_field() with $_REQUESTautofocus? (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.

Location:
branches/6.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.6

  • branches/6.6/src/wp-admin/customize.php

    r58069 r58973  
    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( );
    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( );
     98}
     99if ( ! empty( $autofocus ) ) {
     100    $wp_customize->set_autofocus( );
    99101}
    100102
Note: See TracChangeset for help on using the changeset viewer.