Make WordPress Core


Ignore:
Timestamp:
05/01/2024 05:59:05 PM (13 months ago)
Author:
swissspidy
Message:

General: Remove any usage of wp_reset_vars().

The way wp_reset_vars() sets global variables based on $_POST and $_GET values makes code hard to understand and maintain. It also makes it easy to forget to sanitize input.

This change removes the few places where wp_reset_vars() is used in the admin to explicitly use $_REQUEST and sanitize any input.

Props swissspidy, audrasjb, davideferre, killua99, weijland, voldemortensen.
Fixes #38073.

File:
1 edited

Legend:

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

    r55917 r58069  
    8585}
    8686
    87 
    88 wp_reset_vars( array( 'url', 'return', 'autofocus' ) );
     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'] ) : '';
     90
    8991if ( ! empty( $url ) ) {
    9092    $wp_customize->set_preview_url( wp_unslash( $url ) );
Note: See TracChangeset for help on using the changeset viewer.