2007-05-15 01:17:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarness
|
|
|
|
{
|
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->config->set('HTML', 'Trusted', true);
|
|
|
|
$this->config->set('Core', 'CommentScriptContents', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testDefaultRemoval() {
|
|
|
|
$this->config->set('HTML', 'Trusted', false);
|
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
|
|
|
);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testPreserve() {
|
2007-05-15 01:17:10 +00:00
|
|
|
$this->assertResult(
|
2007-08-07 05:38:22 +00:00
|
|
|
'<script type="text/javascript">foo();</script>'
|
2007-05-15 01:17:10 +00:00
|
|
|
);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testCDATAEnclosure() {
|
2007-06-21 14:44:26 +00:00
|
|
|
$this->assertResult(
|
2007-08-07 05:38:22 +00:00
|
|
|
'<script type="text/javascript">//<![CDATA[
|
2007-06-21 14:44:26 +00:00
|
|
|
alert("<This is compatible with XHTML>");
|
2007-08-07 05:38:22 +00:00
|
|
|
//]]></script>'
|
2007-06-21 14:44:26 +00:00
|
|
|
);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testAllAttributes() {
|
2007-05-15 01:17:10 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<script
|
|
|
|
defer="defer"
|
|
|
|
src="test.js"
|
|
|
|
type="text/javascript"
|
2007-08-07 05:38:22 +00:00
|
|
|
>PCDATA</script>'
|
2007-05-15 01:17:10 +00:00
|
|
|
);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testUnsupportedAttributes() {
|
2007-05-15 01:17:10 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<script
|
|
|
|
type="text/javascript"
|
|
|
|
charset="utf-8"
|
|
|
|
>PCDATA</script>',
|
2007-08-07 05:38:22 +00:00
|
|
|
'<script type="text/javascript">PCDATA</script>'
|
2007-05-15 01:17:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|