From f27ae94140cbc472379c7d80265978b550eb039e Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 2 Dec 2013 22:48:15 +0000 Subject: [PATCH] Customizer: Ensure we have a string that's JSON parseable. props mattwiebe. fixes #postmessage-check.diff. git-svn-id: https://develop.svn.wordpress.org/trunk@26542 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/customize-base.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/js/customize-base.js b/src/wp-includes/js/customize-base.js index 534cf3cf13..db573b5fca 100644 --- a/src/wp-includes/js/customize-base.js +++ b/src/wp-includes/js/customize-base.js @@ -533,6 +533,11 @@ window.wp = window.wp || {}; if ( this.origin() && event.origin !== this.origin() ) return; + // Ensure we have a string that's JSON.parse-able + if ( typeof event.data !== 'string' || event.data[0] !== '{' ) { + return; + } + message = JSON.parse( event.data ); // Check required message properties.