mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-01 11:50:28 +02:00
feat: Add option for safe iframe hosts using array lookup (#423)
Co-authored-by: Edward Z. Yang <ezyang@meta.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
--INI--
|
||||
HTML.SafeIframe = true
|
||||
URI.SafeIframeHosts = www.youtube.com
|
||||
--HTML--
|
||||
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/RVtEQxH7PWA" frameborder="0" allowfullscreen></iframe>
|
||||
--EXPECT--
|
||||
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/RVtEQxH7PWA" frameborder="0"></iframe>
|
||||
--# vim: et sw=4 sts=4
|
@@ -115,6 +115,12 @@ class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
|
||||
$this->assertResult('<iframe src="http://google.com"></iframe>', '');
|
||||
}
|
||||
|
||||
public function testRemoveDisallowedIframeDeniedByHostsList()
|
||||
{
|
||||
$this->config->set('HTML.SafeIframe', true);
|
||||
$this->config->set('URI.SafeIframeHosts', ['www.youtube.com']);
|
||||
$this->assertResult('<iframe src="http://maps.google.com"></iframe>', '');
|
||||
}
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
Reference in New Issue
Block a user