From 4af0279f2a1516db682a427a8b2eb1dceec9bb9b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 11 Oct 2018 04:00:23 +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 5.0 branch. Fixes #44832. Built from https://develop.svn.wordpress.org/branches/5.0@43704 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43533 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 e05bc1e13d..5540bbcfcc 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 62aa754db4..0d35efa282 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-43703'; +$wp_version = '5.0-alpha-43704'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.