mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-04 21:28:06 +02:00
[2.0.1] Scrap auto_close in favor of ChildDef->elements heuristic.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1213 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -10,6 +10,9 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
|
||||
|
||||
$this->obj = new HTMLPurifier_ChildDef_Custom('(a,b?,c*,d+,(a,b)*)');
|
||||
|
||||
$this->assertEqual($this->obj->elements, array('a' => true,
|
||||
'b' => true, 'c' => true, 'd' => true));
|
||||
|
||||
$this->assertResult('', false);
|
||||
$this->assertResult('<a /><a />', false);
|
||||
|
||||
@@ -21,6 +24,8 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
|
||||
|
||||
function testNesting() {
|
||||
$this->obj = new HTMLPurifier_ChildDef_Custom('(a,b,(c|d))+');
|
||||
$this->assertEqual($this->obj->elements, array('a' => true,
|
||||
'b' => true, 'c' => true, 'd' => true));
|
||||
$this->assertResult('', false);
|
||||
$this->assertResult('<a /><b /><c /><a /><b /><d />');
|
||||
$this->assertResult('<a /><b /><c /><d />', false);
|
||||
@@ -28,6 +33,8 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
|
||||
|
||||
function testNestedEitherOr() {
|
||||
$this->obj = new HTMLPurifier_ChildDef_Custom('b,(a|(c|d))+');
|
||||
$this->assertEqual($this->obj->elements, array('a' => true,
|
||||
'b' => true, 'c' => true, 'd' => true));
|
||||
$this->assertResult('', false);
|
||||
$this->assertResult('<b /><a /><c /><d />');
|
||||
$this->assertResult('<b /><d /><a /><a />');
|
||||
@@ -37,6 +44,7 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
|
||||
|
||||
function testNestedQuantifier() {
|
||||
$this->obj = new HTMLPurifier_ChildDef_Custom('(b,c+)*');
|
||||
$this->assertEqual($this->obj->elements, array('b' => true, 'c' => true));
|
||||
$this->assertResult('');
|
||||
$this->assertResult('<b /><c />');
|
||||
$this->assertResult('<b /><c /><c /><c />');
|
||||
@@ -47,6 +55,7 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
|
||||
function testEitherOr() {
|
||||
|
||||
$this->obj = new HTMLPurifier_ChildDef_Custom('a|b');
|
||||
$this->assertEqual($this->obj->elements, array('a' => true, 'b' => true));
|
||||
$this->assertResult('', false);
|
||||
$this->assertResult('<a />');
|
||||
$this->assertResult('<b />');
|
||||
@@ -57,6 +66,7 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
|
||||
function testCommafication() {
|
||||
|
||||
$this->obj = new HTMLPurifier_ChildDef_Custom('a,b');
|
||||
$this->assertEqual($this->obj->elements, array('a' => true, 'b' => true));
|
||||
$this->assertResult('<a /><b />');
|
||||
$this->assertResult('<ab />', false);
|
||||
|
||||
|
@@ -33,10 +33,6 @@ class HTMLPurifier_ElementDefTest extends UnitTestCase
|
||||
$def1->child = $overloaded_old;
|
||||
$def1->content_model = 'old';
|
||||
$def1->content_model_type = $overloaded_old;
|
||||
$def1->auto_close = array(
|
||||
'old' => true,
|
||||
'removed-old' => true
|
||||
);
|
||||
$def1->descendants_are_inline = false;
|
||||
$def1->excludes = array(
|
||||
'old' => true,
|
||||
@@ -60,10 +56,6 @@ class HTMLPurifier_ElementDefTest extends UnitTestCase
|
||||
$def2->child = $new;
|
||||
$def2->content_model = 'new';
|
||||
$def2->content_model_type = $overloaded_new;
|
||||
$def2->auto_close = array(
|
||||
'new' => true,
|
||||
'removed-old' => false
|
||||
);
|
||||
$def2->descendants_are_inline = true;
|
||||
$def2->excludes = array(
|
||||
'new' => true,
|
||||
@@ -90,10 +82,6 @@ class HTMLPurifier_ElementDefTest extends UnitTestCase
|
||||
$this->assertIdentical($def1->child, $new);
|
||||
$this->assertIdentical($def1->content_model, 'old | new');
|
||||
$this->assertIdentical($def1->content_model_type, $overloaded_new);
|
||||
$this->assertIdentical($def1->auto_close, array(
|
||||
'old' => true,
|
||||
'new' => true
|
||||
));
|
||||
$this->assertIdentical($def1->descendants_are_inline, true);
|
||||
$this->assertIdentical($def1->excludes, array(
|
||||
'old' => true,
|
||||
|
@@ -20,7 +20,7 @@ class HTMLPurifier_Strategy_CoreTest extends HTMLPurifier_StrategyHarness
|
||||
);
|
||||
$this->assertResult(
|
||||
'<b><div>Fix nesting.</div></b>',
|
||||
'<b>Fix nesting.</b>'
|
||||
'<b></b><div>Fix nesting.</div>'
|
||||
);
|
||||
$this->assertResult(
|
||||
'<asdf>Foreign element removal.</asdf>',
|
||||
@@ -28,7 +28,7 @@ class HTMLPurifier_Strategy_CoreTest extends HTMLPurifier_StrategyHarness
|
||||
);
|
||||
$this->assertResult(
|
||||
'<foo><b><div>All three.</div></b>',
|
||||
'<b>All three.</b>'
|
||||
'<b></b><div>All three.</div>'
|
||||
);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user