Skip to content

Commit 0247ae7

Browse files
committed
notes plugin allows messsages from current/upcoming slide windows
1 parent 3140708 commit 0247ae7

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

plugin/notes/notes.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/notes/notes.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/notes/plugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ const Plugin = () => {
203203
// that we remain connected to the notes even if the presentation
204204
// is reloaded.
205205
window.addEventListener( 'message', event => {
206+
206207
if( !speakerWindow && typeof event.data === 'string' ) {
207208
let data;
208209

plugin/notes/speaker-view.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ <h4 class="label">Notes</h4>
350350
layoutDropdown,
351351
pendingCalls = {},
352352
lastRevealApiCallId = 0,
353-
connected = false;
353+
connected = false,
354+
whitelistedWindows = [window.opener];
354355

355356
var SPEAKER_LAYOUTS = {
356357
'default': 'Default',
@@ -368,8 +369,8 @@ <h4 class="label">Notes</h4>
368369
;
369370
window.addEventListener( 'message', function( event ) {
370371

371-
// Validate the origin of this message to avoid XSS
372-
if( window.location.origin !== event.origin && event.source !== window.opener ) {
372+
// Validate the origin of this message to prevent XSS
373+
if( window.location.origin !== event.origin && whitelistedWindows.indexOf( event.source ) === -1 ) {
373374
return;
374375
}
375376

@@ -538,6 +539,8 @@ <h4 class="label">Notes</h4>
538539
upcomingSlide.setAttribute( 'src', upcomingURL );
539540
document.querySelector( '#upcoming-slide' ).appendChild( upcomingSlide );
540541

542+
whitelistedWindows.push( currentSlide.contentWindow, upcomingSlide.contentWindow );
543+
541544
}
542545

543546
/**

0 commit comments

Comments
 (0)