diff --git a/test/core/HTMLDOMSanitizerTest.php b/test/core/HTMLDOMSanitizerTest.php index 004b1cc74..e5c74db1a 100644 --- a/test/core/HTMLDOMSanitizerTest.php +++ b/test/core/HTMLDOMSanitizerTest.php @@ -202,5 +202,80 @@ class HTMLDOMSanitizerTest extends ItopTestCase return true; } + + /** + * @dataProvider RemoveBlackListedTagContentProvider + */ + public function testDoSanitizeRemoveBlackListedTagContent($html, $expected) + { + $oSanitizer = new HTMLDOMSanitizer(); + $sSanitizedHtml = $oSanitizer->DoSanitize($html); + + $this->assertEquals($expected, str_replace("\n", '', $sSanitizedHtml)); + } + + public function RemoveBlackListedTagContentProvider() + { + return array( + 'basic' => array( + 'html' => 'foobaz', + 'expected' => '
foobaz
', + ), + 'basic with body' => array( + 'html' => 'foobaz', + 'expected' => 'foobaz', + ), + 'basic with html and body tags' => array( + 'html' => 'foobaz', + 'expected' => 'foobaz', + ), + 'basic with attributes' => array( + 'html' => 'foobaz', + 'expected' => 'foobaz
', + ), + 'basic with comment' => array( + 'html' => 'foobaz', + 'expected' => 'foobaz
', + ), + 'basic with contentRemovable tag' => array( + 'html' => 'foobaz', + 'expected' => 'foobaz
', + ), + 'nested' => array( + 'html' => 'beforeafter', + 'expected' => 'beforeafter
', + ), + 'nested with not closed br' => array( + 'html' => 'beforebeforeafter
', + ), + 'nested with allowed' => array( + 'html' => 'beforebaz
zabbeforeafter
', + ), + 'nested with spaces' => array( + 'html' => 'beforebeforeafter
', + ), + 'nested with attributes' => array( + 'html' => 'beforebeforeafter
', + ), + 'nested with allowed and attributes and spaces ' => array( + 'html' => 'before