mirror of
https://github.com/hakimel/reveal.js.git
synced 2025-07-31 03:40:28 +02:00
Merge pull request #3548 from hackmdio/fix/xss-on-data-background-video-attribute
fix: use `setAttribute` instead of `innerHTML` to prevent XSS
This commit is contained in:
@@ -142,13 +142,15 @@ export default class SlideContent {
|
|||||||
|
|
||||||
// Support comma separated lists of video sources
|
// Support comma separated lists of video sources
|
||||||
backgroundVideo.split( ',' ).forEach( source => {
|
backgroundVideo.split( ',' ).forEach( source => {
|
||||||
|
const sourceElement = document.createElement( 'source' );
|
||||||
|
sourceElement.setAttribute( 'src', source );
|
||||||
|
|
||||||
let type = getMimeTypeFromFile( source );
|
let type = getMimeTypeFromFile( source );
|
||||||
if( type ) {
|
if( type ) {
|
||||||
video.innerHTML += `<source src="${source}" type="${type}">`;
|
sourceElement.setAttribute( 'type', type );
|
||||||
}
|
|
||||||
else {
|
|
||||||
video.innerHTML += `<source src="${source}">`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
video.appendChild( sourceElement );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
backgroundContent.appendChild( video );
|
backgroundContent.appendChild( video );
|
||||||
|
Reference in New Issue
Block a user