2007-05-15 01:17:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/HTMLModuleHarness.php';
|
|
|
|
|
|
|
|
class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarness
|
|
|
|
{
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
2007-06-16 19:31:45 +00:00
|
|
|
// default (remove everything)
|
2007-05-15 01:17:10 +00:00
|
|
|
$this->assertResult(
|
2007-06-16 19:31:45 +00:00
|
|
|
'<script type="text/javascript">foo();</script>', ''
|
2007-05-15 01:17:10 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// enabled
|
|
|
|
$this->assertResult(
|
|
|
|
'<script type="text/javascript">foo();</script>', true,
|
|
|
|
array('HTML.Trusted' => true)
|
|
|
|
);
|
|
|
|
|
|
|
|
// max
|
|
|
|
$this->assertResult(
|
|
|
|
'<script
|
|
|
|
defer="defer"
|
|
|
|
src="test.js"
|
|
|
|
type="text/javascript"
|
|
|
|
>PCDATA</script>', true,
|
|
|
|
array('HTML.Trusted' => true, 'Core.CommentScriptContents' => false)
|
|
|
|
);
|
|
|
|
|
|
|
|
// unsupported
|
|
|
|
$this->assertResult(
|
|
|
|
'<script
|
|
|
|
type="text/javascript"
|
|
|
|
charset="utf-8"
|
|
|
|
>PCDATA</script>',
|
|
|
|
'<script type="text/javascript">PCDATA</script>',
|
|
|
|
array('HTML.Trusted' => true, 'Core.CommentScriptContents' => false)
|
|
|
|
);
|
|
|
|
|
|
|
|
// invalid children
|
|
|
|
$this->assertResult(
|
|
|
|
'<script type="text/javascript">PCDATA<span</script>',
|
|
|
|
'<script type="text/javascript">PCDATA</script>',
|
|
|
|
array('HTML.Trusted' => true, 'Core.CommentScriptContents' => false)
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|