From e92c6a2817d4aaf0e0a707b217fed19c2dc7cfed Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 31 Aug 2018 06:29:28 +0000 Subject: [PATCH] Embeds: Avoid a JS error in `wp.receiveEmbedMessage` if `data` parameter is not set. Props dsifford, kadamwhite. Merges [43593] and [43597] to the 4.9 branch. Fixes #44832. Built from https://develop.svn.wordpress.org/branches/4.9@43600 git-svn-id: http://core.svn.wordpress.org/branches/4.9@43429 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/embed.php | 2 +- wp-includes/js/wp-embed.js | 5 +++++ wp-includes/js/wp-embed.min.js | 2 +- wp-includes/version.php | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-includes/embed.php b/wp-includes/embed.php index d9aba2e00c..9f52259182 100644 --- a/wp-includes/embed.php +++ b/wp-includes/embed.php @@ -450,7 +450,7 @@ function get_post_embed_html( $width, $height, $post = null ) { * and edit wp-embed.js directly. */ $output .=<<1e3)g=1e3;else if(~~g<200)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document); + !function(a,b){"use strict";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf("MSIE 10"),h=!!navigator.userAgent.match(/Trident.*rv:11\./),i=b.querySelectorAll("iframe.wp-embedded-content");for(c=0;c1e3)g=1e3;else if(~~g<200)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document); JS; } $output .= "\n//-->"; diff --git a/wp-includes/js/wp-embed.js b/wp-includes/js/wp-embed.js index a25e09e8ed..17270b05d8 100644 --- a/wp-includes/js/wp-embed.js +++ b/wp-includes/js/wp-embed.js @@ -28,6 +28,11 @@ window.wp.receiveEmbedMessage = function( e ) { var data = e.data; + + if ( ! data ) { + return; + } + if ( ! ( data.secret || data.message || data.value ) ) { return; } diff --git a/wp-includes/js/wp-embed.min.js b/wp-includes/js/wp-embed.min.js index 69c1f01c58..78f9c6431b 100644 --- a/wp-includes/js/wp-embed.min.js +++ b/wp-includes/js/wp-embed.min.js @@ -1 +1 @@ -!function(a,b){"use strict";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf("MSIE 10"),h=!!navigator.userAgent.match(/Trident.*rv:11\./),i=b.querySelectorAll("iframe.wp-embedded-content");for(c=0;c1e3)g=1e3;else if(~~g<200)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document); \ No newline at end of file +!function(a,b){"use strict";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf("MSIE 10"),h=!!navigator.userAgent.match(/Trident.*rv:11\./),i=b.querySelectorAll("iframe.wp-embedded-content");for(c=0;c1e3)g=1e3;else if(~~g<200)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 29a67a3347..269af040cd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9.9-alpha-43575'; +$wp_version = '4.9.9-alpha-43600'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.