Skip to content

Commit

Permalink
fix: use setAttribute instead of innerHTML to prevent xss
Browse files Browse the repository at this point in the history
  • Loading branch information
EastSun5566 committed Dec 15, 2023
1 parent 993b8f3 commit 89ab00a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/controllers/slidecontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@ export default class SlideContent {

// Support comma separated lists of video sources
backgroundVideo.split( ',' ).forEach( source => {
const sourceElement = document.createElement( 'source' );
sourceElement.setAttribute( 'src', source );

let type = getMimeTypeFromFile( source );
if( type ) {
video.innerHTML += `<source src="${source}" type="${type}">`;
}
else {
video.innerHTML += `<source src="${source}">`;
sourceElement.setAttribute( 'type', type );
}

video.appendChild( sourceElement );
} );

backgroundContent.appendChild( video );
Expand Down

0 comments on commit 89ab00a

Please sign in to comment.