File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ protected function buildIframe(): string {
405405
406406 $ attributes = $ this ->buildAttributeString ();
407407
408- return sprintf ('<iframe src="%s"%s></iframe> ' , $ source , $ attributes );
408+ return sprintf ('<iframe src="%s"%s></iframe> ' , $ this -> esc ( $ source) , $ attributes );
409409 }
410410
411411 /**
Original file line number Diff line number Diff line change @@ -234,6 +234,26 @@ public function testEmbedCodeWithCustomAttributesAndParams(): void {
234234 $ this ->assertStringNotContainsString (' hidden ' , $ code );
235235 }
236236
237+ public function testEmbedCodeEscapesIframeSource (): void {
238+ $ MediaEmbed = new MediaEmbed ();
239+ $ MediaEmbed ->addProviderConfig (new ProviderConfig (
240+ name: 'UnsafeProvider ' ,
241+ website: 'https://unsafe.example.com ' ,
242+ urlMatch: 'https://unsafe \\.example \\.com/video/([0-9]+) ' ,
243+ embedWidth: 640 ,
244+ embedHeight: 360 ,
245+ iframePlayer: '//unsafe.example.com/embed/$2?foo=1&bar="quoted" ' ,
246+ ));
247+
248+ $ Object = $ MediaEmbed ->parseUrl ('https://unsafe.example.com/video/12345 ' );
249+ $ this ->assertInstanceOf (MediaObject::class, $ Object );
250+
251+ $ code = $ Object ->getEmbedCode ();
252+
253+ $ this ->assertStringContainsString ('src="//unsafe.example.com/embed/12345?foo=1&bar="quoted"&wmode=transparent" ' , $ code );
254+ $ this ->assertStringNotContainsString ('bar="quoted" ' , $ code );
255+ }
256+
237257 /**
238258 * Test YouTube /live/ URL format
239259 *
You can’t perform that action at this time.
0 commit comments