diff --git a/tests/unit/framework/security/HTMLFilterTest.php b/tests/unit/framework/security/HTMLFilterTest.php index e29ae9438..f3ab22629 100644 --- a/tests/unit/framework/security/HTMLFilterTest.php +++ b/tests/unit/framework/security/HTMLFilterTest.php @@ -2,67 +2,82 @@ class HTMLFilterTest extends \Codeception\TestCase\Test { - public function testRemoveHackTag() - { - $tests = array( - // remove iframe - array( - '

IFrame

', - '

IFrame

' - ), - // expression - array( - '
', - '
' - ), - // no quotes and no semicolon - http://ha.ckers.org/xss.html - array( - '', - '' - ), - // embedded encoded tab to break up XSS - http://ha.ckers.org/xss.html - array( - '', - '' - ), - // issue 178 - array( - '', - '' - ), - // issue 534 - array( - '*/" onerror="console.log(\'Yet another XSS\')">', - '*/" onerror="console.log(\'Yet another XSS\')">' - ), - // issue 602 - array( - 'test', - 'test' - ), - // issue #1813 https://github.com/xpressengine/xe-core/issues/1813 - array( - 'dummy', - 'dummy' - ), - array( - 'dummy', - 'dummy' - ), - array( - "\"dummy\"", - 'dummy' - ), - array( - "\"dummy\"", - 'dummy' - ) - ); - - foreach ($tests as $test) - { - $result = removeHackTag($test[0]); - $this->assertEquals($test[1], $result); - } - } + public function testRemoveHackTag() + { + $tests = array( + // remove iframe + array( + '

IFrame

', + '

IFrame

' + ), + // expression + array( + '
', + '
' + ), + // no quotes and no semicolon - http://ha.ckers.org/xss.html + array( + '', + '' + ), + // embedded encoded tab to break up XSS - http://ha.ckers.org/xss.html + array( + '', + '' + ), + // issue 178 + array( + '', + '' + ), + // issue 534 + array( + '*/" onerror="console.log(\'Yet another XSS\')">', + '*/" onerror="console.log(\'Yet another XSS\')">' + ), + // issue 602 + array( + 'test', + 'test' + ), + // issue #1813 https://github.com/xpressengine/xe-core/issues/1813 + array( + 'dummy', + 'dummy' + ), + array( + 'dummy', + 'dummy' + ), + array( + "\"dummy\"", + 'dummy' + ), + array( + "\"dummy\"", + 'dummy' + ) + ); + + foreach ($tests as $test) + { + $this->assertEquals($test[1], removeHackTag($test[0])); + } + } + + public function testRemoveEmbeddedMedia() + { + $tests = array( + '
' => '
', + '
' => '
', + '
' => '
', + '
' => '
', + '
' => '
', + ); + + foreach ($tests as $from => $to) + { + $this->assertEquals($to, Rhymix\Framework\Security\HTMLFilter::removeEmbeddedMedia($from)); + } + } }