Customize: Ignore invalid customization sessions.
Merge of [40704] to the 3.9 branch. Built from https://develop.svn.wordpress.org/branches/3.9@40713 git-svn-id: http://core.svn.wordpress.org/branches/3.9@40576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c2f264d25f
commit
9febffc6f7
|
@ -1004,6 +1004,16 @@
|
|||
}
|
||||
});
|
||||
|
||||
// Ensure preview nonce is included with every customized request, to allow post data to be read.
|
||||
$.ajaxPrefilter( function injectPreviewNonce( options ) {
|
||||
if ( ! /wp_customize=on/.test( options.data ) ) {
|
||||
return;
|
||||
}
|
||||
options.data += '&' + $.param({
|
||||
customize_preview_nonce: api.settings.nonce.preview
|
||||
});
|
||||
});
|
||||
|
||||
// Refresh the nonces if the preview sends updated nonces over.
|
||||
previewer.bind( 'nonce', function( nonce ) {
|
||||
$.extend( this.nonce, nonce );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -163,6 +163,24 @@ final class WP_Customize_Manager {
|
|||
|
||||
$this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null );
|
||||
|
||||
/*
|
||||
* Clear incoming post data if the user lacks a CSRF token (nonce). Note that the customizer
|
||||
* application will inject the customize_preview_nonce query parameter into all Ajax requests.
|
||||
* For similar behavior elsewhere in WordPress, see rest_cookie_check_errors() which logs out
|
||||
* a user when a valid nonce isn't present.
|
||||
*/
|
||||
$has_post_data_nonce = (
|
||||
check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce', false )
|
||||
||
|
||||
check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce', false )
|
||||
||
|
||||
check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'customize_preview_nonce', false )
|
||||
);
|
||||
if ( ! $has_post_data_nonce ) {
|
||||
unset( $_POST['customized'] );
|
||||
unset( $_REQUEST['customized'] );
|
||||
}
|
||||
|
||||
if ( $this->is_theme_active() ) {
|
||||
// Once the theme is loaded, we'll validate it.
|
||||
add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
|
||||
|
|
Loading…
Reference in New Issue