From e178acf1085070742cd6434fd262d946cc570eff Mon Sep 17 00:00:00 2001 From: koopersmith Date: Sat, 26 May 2012 04:08:44 +0000 Subject: [PATCH] Theme Customizer: Add a signature to preview requests to be super-double-ultra-sure that the customizer generated the preview. Redirects can be sneaky. fixes #20507, see #19910. git-svn-id: http://core.svn.wordpress.org/trunk@20925 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-manager.php | 10 ++++++++++ wp-includes/js/customize-controls.dev.js | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index fda9f2f4c..1de06949e 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -264,6 +264,7 @@ final class WP_Customize_Manager { wp_enqueue_script( 'customize-preview' ); add_action( 'wp_head', array( $this, 'customize_preview_base' ) ); add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 ); + add_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 ); foreach ( $this->settings as $setting ) { $setting->preview(); @@ -302,6 +303,15 @@ final class WP_Customize_Manager { ') ) + return; + + // Strip the signature from the request. + response = response.slice( 0, index ) + response.slice( index + signature.length ); + self.loader().one( 'load', self.loaded ); iframe.document.open();