1
0
Эх сурвалжийг харах

Merge pull request #3548 from hackmdio/fix/xss-on-data-background-video-attribute

fix: use `setAttribute` instead of `innerHTML` to prevent XSS
Hakim El Hattab 1 жил өмнө
parent
commit
767a67ee00

+ 6 - 4
js/controllers/slidecontent.js

@@ -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 );