浏览代码

notes plugin allows messsages from current/upcoming slide windows

hakimel 3 年之前
父节点
当前提交
0247ae7582
共有 4 个文件被更改,包括 7 次插入3 次删除
  1. 0 0
      plugin/notes/notes.esm.js
  2. 0 0
      plugin/notes/notes.js
  3. 1 0
      plugin/notes/plugin.js
  4. 6 3
      plugin/notes/speaker-view.html

文件差异内容过多而无法显示
+ 0 - 0
plugin/notes/notes.esm.js


文件差异内容过多而无法显示
+ 0 - 0
plugin/notes/notes.js


+ 1 - 0
plugin/notes/plugin.js

@@ -203,6 +203,7 @@ const Plugin = () => {
 					// that we remain connected to the notes even if the presentation
 					// is reloaded.
 					window.addEventListener( 'message', event => {
+
 						if( !speakerWindow && typeof event.data === 'string' ) {
 							let data;
 

+ 6 - 3
plugin/notes/speaker-view.html

@@ -350,7 +350,8 @@
 					layoutDropdown,
 					pendingCalls = {},
 					lastRevealApiCallId = 0,
-					connected = false;
+					connected = false,
+					whitelistedWindows = [window.opener];
 
 				var SPEAKER_LAYOUTS = {
 					'default': 'Default',
@@ -368,8 +369,8 @@
 ;
 				window.addEventListener( 'message', function( event ) {
 
-					// Validate the origin of this message to avoid XSS
-					if( window.location.origin !== event.origin && event.source !== window.opener ) {
+					// Validate the origin of this message to prevent XSS
+					if( window.location.origin !== event.origin && whitelistedWindows.indexOf( event.source ) === -1 ) {
 						return;
 					}
 
@@ -538,6 +539,8 @@
 					upcomingSlide.setAttribute( 'src', upcomingURL );
 					document.querySelector( '#upcoming-slide' ).appendChild( upcomingSlide );
 
+					whitelistedWindows.push( currentSlide.contentWindow, upcomingSlide.contentWindow );
+
 				}
 
 				/**

部分文件因为文件数量过多而无法显示