diff --git a/library/HTMLPurifier/HTMLDefinition.php b/library/HTMLPurifier/HTMLDefinition.php index aaeb8bae..fe6bd141 100644 --- a/library/HTMLPurifier/HTMLDefinition.php +++ b/library/HTMLPurifier/HTMLDefinition.php @@ -330,7 +330,7 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition if (isset($this->info_content_sets['Block'][$block_wrapper])) { $this->info_block_wrapper = $block_wrapper; } else { - trigger_error('Cannot use non-block element as block wrapper.', + trigger_error('Cannot use non-block element as block wrapper', E_USER_ERROR); } @@ -340,7 +340,7 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition $this->info_parent = $parent; $this->info_parent_def = $def; } else { - trigger_error('Cannot use unrecognized element as parent.', + trigger_error('Cannot use unrecognized element as parent', E_USER_ERROR); $this->info_parent_def = $this->manager->getElement($this->info_parent, true); } diff --git a/tests/HTMLPurifier/ChildDef/StrictBlockquoteTest.php b/tests/HTMLPurifier/ChildDef/StrictBlockquoteTest.php index 788c7a36..256d3a34 100644 --- a/tests/HTMLPurifier/ChildDef/StrictBlockquoteTest.php +++ b/tests/HTMLPurifier/ChildDef/StrictBlockquoteTest.php @@ -74,6 +74,7 @@ extends HTMLPurifier_ChildDefHarness } function testError() { + $this->expectError('Cannot use non-block element as block wrapper'); $this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p'); $this->config->set('HTML', 'BlockWrapper', 'dav'); $this->assertResult('Needs wrap', '

Needs wrap

'); diff --git a/tests/HTMLPurifier/ChildDef/TableTest.php b/tests/HTMLPurifier/ChildDef/TableTest.php index 209e2a57..62247d23 100644 --- a/tests/HTMLPurifier/ChildDef/TableTest.php +++ b/tests/HTMLPurifier/ChildDef/TableTest.php @@ -3,6 +3,9 @@ require_once 'HTMLPurifier/ChildDefHarness.php'; require_once 'HTMLPurifier/ChildDef/Table.php'; +// we're using empty tags to compact the tests: under real circumstances +// there would be contents in them + class HTMLPurifier_ChildDef_TableTest extends HTMLPurifier_ChildDefHarness { @@ -11,40 +14,47 @@ class HTMLPurifier_ChildDef_TableTest extends HTMLPurifier_ChildDefHarness $this->obj = new HTMLPurifier_ChildDef_Table(); } - function test() { + function testEmptyInput() { $this->assertResult('', false); - - // we're using empty tags to compact the tests: under real circumstances - // there would be contents in them - + } + + function testSingleRow() { $this->assertResult(''); + } + + function testComplexContents() { $this->assertResult(''. 'asdf'); $this->assertResult(''); - - // mixed up order + } + + function testReorderContents() { $this->assertResult( '1', '1'); - - // duplicates of singles - // - first caption serves - // - trailing tfoots/theads get turned into tbodys + } + + function testDuplicateProcessing() { $this->assertResult( '11', '11' ); - - // errant text dropped (until bubbling is implemented) + } + + function testRemoveText() { $this->assertResult('foo', false); - - // whitespace sticks to the previous element, last whitespace is - // stationary - $this->assertResult("\n \n \n ", true, array('Output.Newline' => "\n")); + } + + function testStickyWhitespaceOnTr() { + $this->config->set('Output', 'Newline', "\n"); + $this->assertResult("\n \n \n "); + } + + function testStickyWhitespaceOnTSection() { + $this->config->set('Output', 'Newline', "\n"); $this->assertResult( "\n\t\n\t\t\n\t\t\t", - "\n\t\t\n\t\n\t\t\t", - array('Output.Newline' => "\n") + "\n\t\t\n\t\n\t\t\t" ); } diff --git a/tests/HTMLPurifier/HTMLModule/ScriptingTest.php b/tests/HTMLPurifier/HTMLModule/ScriptingTest.php index 2bb4a0e8..7f4151fd 100644 --- a/tests/HTMLPurifier/HTMLModule/ScriptingTest.php +++ b/tests/HTMLPurifier/HTMLModule/ScriptingTest.php @@ -5,47 +5,51 @@ require_once 'HTMLPurifier/HTMLModuleHarness.php'; class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarness { - function test() { - - // default (remove everything) + function setUp() { + parent::setUp(); + $this->config->set('HTML', 'Trusted', true); + $this->config->set('Core', 'CommentScriptContents', false); + } + + function testDefaultRemoval() { + $this->config->set('HTML', 'Trusted', false); $this->assertResult( '', '' ); - - // enabled + } + + function testPreserve() { $this->assertResult( - '', true, - array('HTML.Trusted' => true) + '' ); - - // CDATA + } + + function testCDATAEnclosure() { $this->assertResult( -'////"); -//]]> ', true, - array('HTML.Trusted' => true) +//]]>' ); - - // max + } + + function testAllAttributes() { $this->assertResult( '', true, - array('HTML.Trusted' => true, 'Core.CommentScriptContents' => false) + >PCDATA' ); - - // unsupported + } + + function testUnsupportedAttributes() { $this->assertResult( '', - '', - array('HTML.Trusted' => true, 'Core.CommentScriptContents' => false) + '' ); - } }