2007-05-15 01:17:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->config->set('HTML', 'Trusted', true);
|
2008-04-03 21:53:06 +00:00
|
|
|
$this->config->set('Output', 'CommentScriptContents', false);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
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
|
|
|
}
|
2008-12-06 07:28:20 +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
|
|
|
}
|
2008-12-06 07:28:20 +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
|
|
|
}
|
2008-12-06 07:28:20 +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
|
|
|
}
|
2008-12-06 07:28:20 +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
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-05-15 01:17:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|