Skip to content

Commit

Permalink
notes plugin allows messsages from current/upcoming slide windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Mar 21, 2022
1 parent 3140708 commit 0247ae7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugin/notes/notes.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugin/notes/notes.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugin/notes/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 6 additions & 3 deletions plugin/notes/speaker-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ <h4 class="label">Notes</h4>
layoutDropdown,
pendingCalls = {},
lastRevealApiCallId = 0,
connected = false;
connected = false,
whitelistedWindows = [window.opener];

var SPEAKER_LAYOUTS = {
'default': 'Default',
Expand All @@ -368,8 +369,8 @@ <h4 class="label">Notes</h4>
;
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;
}

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

whitelistedWindows.push( currentSlide.contentWindow, upcomingSlide.contentWindow );

}

/**
Expand Down

0 comments on commit 0247ae7

Please sign in to comment.