Make WordPress Core

Changeset 40710


Ignore:
Timestamp:
05/16/2017 12:18:10 PM (8 years ago)
Author:
ocean90
Message:

Customize: Ignore invalid customization sessions.

Merge of [40704] to the 4.2 branch.

Location:
branches/4.2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2

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

    r37772r40710 
    149149                <div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Customizer Options' ); ?>" tabindex="0">
    150150                    <span class="preview-notice"><?php
    151                         echo sprintf( __( 'You are customizing %s' ), '<strong class="theme-name site-title">' . get_bloginfo( 'name' ) . '</strong>' );
     151                        echo sprintf( __( 'You are customizing %s' ), '<strong class="theme-name site-title">' . get_bloginfo( 'name', 'display' ) . '</strong>' );
    152152                    ?></span>
    153153                </div>
  • branches/4.2/src/wp-admin/js/customize-controls.js

    r32119r40710 
    27042704        });
    27052705
     2706        // Ensure preview nonce is included with every customized request, to allow post data to be read.
     2707        $.ajaxPrefilter( function injectPreviewNonce( options ) {
     2708            if ( ! /wp_customize=on/.test( options.data ) ) {
     2709                return;
     2710            }
     2711            options.data += '&' + $.param({
     2712                customize_preview_nonce: api.settings.nonce.preview
     2713            });
     2714        });
     2715
    27062716        // Refresh the nonces if the preview sends updated nonces over.
    27072717        api.previewer.bind( 'nonce', function( nonce ) {
  • branches/4.2/src/wp-includes/class-wp-customize-manager.php

    r32265r40710 
    196196
    197197        show_admin_bar( false );
     198
     199        /*
     200         * Clear incoming post data if the user lacks a CSRF token (nonce). Note that the customizer
     201         * application will inject the customize_preview_nonce query parameter into all Ajax requests.
     202         * For similar behavior elsewhere in WordPress, see rest_cookie_check_errors() which logs out
     203         * a user when a valid nonce isn't present.
     204         */
     205        $has_post_data_nonce = (
     206            check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce', false )
     207            ||
     208            check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce', false )
     209            ||
     210            check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'customize_preview_nonce', false )
     211        );
     212        if ( ! $has_post_data_nonce ) {
     213            unset( $_POST['customized'] );
     214            unset( $_REQUEST['customized'] );
     215        }
    198216
    199217        if ( ! current_user_can( 'customize' ) ) {
Note: See TracChangeset for help on using the changeset viewer.