Make WordPress Core


Ignore:
Timestamp:
05/16/2017 12:19:04 PM (9 years ago)
Author:
ocean90
Message:

Customize: Ignore invalid customization sessions.

Merge of [40704] to the 4.1 branch.

Location:
branches/4.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1

  • branches/4.1/src/wp-includes/class-wp-customize-manager.php

    r31410 r40711  
    176176                $this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null );
    177177
     178                /*
     179                 * Clear incoming post data if the user lacks a CSRF token (nonce). Note that the customizer
     180                 * application will inject the customize_preview_nonce query parameter into all Ajax requests.
     181                 * For similar behavior elsewhere in WordPress, see rest_cookie_check_errors() which logs out
     182                 * a user when a valid nonce isn't present.
     183                 */
     184                $has_post_data_nonce = (
     185                        check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce', false )
     186                        ||
     187                        check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce', false )
     188                        ||
     189                        check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'customize_preview_nonce', false )
     190                );
     191                if ( ! $has_post_data_nonce ) {
     192                        unset( $_POST['customized'] );
     193                        unset( $_REQUEST['customized'] );
     194                }
     195
    178196                if ( $this->is_theme_active() ) {
    179197                        // Once the theme is loaded, we'll validate it.
Note: See TracChangeset for help on using the changeset viewer.