1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-07 06:36:44 +02:00

- Implement double-checking in Strategy/FixNesting.php, fixes the table bugs.

- Move around child definitions so they make a little more sense (rename to Custom) and also add $allow_empty property to help FixNesting.php determine whether or not to double-check.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@136 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-07-31 03:04:57 +00:00
parent 9c6ae16764
commit 9d411bd5cc
5 changed files with 87 additions and 42 deletions

View File

@@ -30,10 +30,10 @@ class HTMLPurifier_ChildDefTest extends UnitTestCase
}
}
function test_complex() {
function test_custom() {
// the table definition
$def = new HTMLPurifier_ChildDef(
$def = new HTMLPurifier_ChildDef_Custom(
'(caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))');
$inputs[0] = '';
@@ -56,12 +56,9 @@ class HTMLPurifier_ChildDefTest extends UnitTestCase
}
function test_simple() {
function test_parsing() {
// simple is actually an abstract class
// but we're unit testing some of the conv. functions it gives
$def = new HTMLPurifier_ChildDef_Simple('foobar | bang |gizmo');
$def = new HTMLPurifier_ChildDef_Required('foobar | bang |gizmo');
$this->assertEqual($def->elements,
array(
'foobar' => true
@@ -69,7 +66,7 @@ class HTMLPurifier_ChildDefTest extends UnitTestCase
,'gizmo' => true
));
$def = new HTMLPurifier_ChildDef_Simple(array('href', 'src'));
$def = new HTMLPurifier_ChildDef_Required(array('href', 'src'));
$this->assertEqual($def->elements,
array(
'href' => true

View File

@@ -38,9 +38,29 @@ class HTMLPurifier_Strategy_FixNestingTest
$expect[4] = '<ul><li>Legal item</li></ul>';
// test custom table definition
$inputs[5] = '<table><tr><td>Cell 1</td></tr></table>';
$expect[5] = '<table><tr><td>Cell 1</td></tr></table>';
$inputs[6] = '<table></table>';
$expect[6] = '';
// breaks without the redundant checking code
$inputs[7] = '<table><tr></tr></table>';
$expect[7] = '';
// special case, prevents scrolling one back to find parent
$inputs[8] = '<table><tr></tr><tr></tr></table>';
$expect[8] = '';
// cascading rollbacks
$inputs[9] = '<table><tbody><tr></tr><tr></tr></tbody><tr></tr><tr></tr></table>';
$expect[9] = '';
// rollbacks twice
$inputs[10] = '<table></table><table></table>';
$expect[10] = '';
$this->assertStrategyWorks($strategy, $inputs, $expect);
}