Make WordPress Core

Changeset 40712 for branches/4.0


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

Customize: Ignore invalid customization sessions.

Merge of [40704] to the 4.0 branch.

Location:
branches/4.0
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

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

    r37775 r40712  
    142142                        } else {
    143143                            /* translators: %s is the site/panel title in the Customize pane */
    144                             echo sprintf( __( 'You are customizing %s' ), '<strong class="theme-name site-title">' . get_bloginfo( 'name' ) . '</strong>' );
     144                            echo sprintf( __( 'You are customizing %s' ), '<strong class="theme-name site-title">' . get_bloginfo( 'name', 'display' ) . '</strong>' );
    145145                        }
    146146                    ?></span>
  • branches/4.0/src/wp-admin/js/customize-controls.js

    r29451 r40712  
    10871087        });
    10881088
     1089        // Ensure preview nonce is included with every customized request, to allow post data to be read.
     1090        $.ajaxPrefilter( function injectPreviewNonce( options ) {
     1091            if ( ! /wp_customize=on/.test( options.data ) ) {
     1092                return;
     1093            }
     1094            options.data += '&' + $.param({
     1095                customize_preview_nonce: api.settings.nonce.preview
     1096            });
     1097        });
     1098
    10891099        // Refresh the nonces if the preview sends updated nonces over.
    10901100        api.previewer.bind( 'nonce', function( nonce ) {
  • branches/4.0/src/wp-includes/class-wp-customize-manager.php

    r29488 r40712  
    166166
    167167        $this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null );
     168
     169        /*
     170         * Clear incoming post data if the user lacks a CSRF token (nonce). Note that the customizer
     171         * application will inject the customize_preview_nonce query parameter into all Ajax requests.
     172         * For similar behavior elsewhere in WordPress, see rest_cookie_check_errors() which logs out
     173         * a user when a valid nonce isn't present.
     174         */
     175        $has_post_data_nonce = (
     176            check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce', false )
     177            ||
     178            check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce', false )
     179            ||
     180            check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'customize_preview_nonce', false )
     181        );
     182        if ( ! $has_post_data_nonce ) {
     183            unset( $_POST['customized'] );
     184            unset( $_REQUEST['customized'] );
     185        }
    168186
    169187        if ( $this->is_theme_active() ) {
Note: See TracChangeset for help on using the changeset viewer.