3 class HTMLPurifier_Strategy_FixNestingTest
extends HTMLPurifier_StrategyHarness
8 $this->obj
= new HTMLPurifier_Strategy_FixNesting();
11 function testPreserveInlineInRoot() {
12 $this->assertResult('<b>Bold text</b>');
15 function testPreserveInlineAndBlockInRoot() {
16 $this->assertResult('<a href="about:blank">Blank</a><div>Block</div>');
19 function testRemoveBlockInInline() {
21 '<b><div>Illegal div.</div></b>',
26 function testEscapeBlockInInline() {
27 $this->config
->set('Core.EscapeInvalidChildren', true);
29 '<b><div>Illegal div.</div></b>',
30 '<b><div>Illegal div.</div></b>'
34 function testRemoveNodeWithMissingRequiredElements() {
35 $this->assertResult('<ul></ul>', '');
38 function testListHandleIllegalPCDATA() {
40 '<ul>Illegal text<li>Legal item</li></ul>',
41 '<ul><li>Illegal text</li><li>Legal item</li></ul>'
45 function testRemoveIllegalPCDATA() {
47 '<table><tr>Illegal text<td></td></tr></table>',
48 '<table><tr><td></td></tr></table>'
52 function testCustomTableDefinition() {
53 $this->assertResult('<table><tr><td>Cell 1</td></tr></table>');
56 function testRemoveEmptyTable() {
57 $this->assertResult('<table></table>', '');
60 function testChameleonRemoveBlockInNodeInInline() {
62 '<span><ins><div>Not allowed!</div></ins></span>',
63 '<span><ins>Not allowed!</ins></span>'
67 function testChameleonRemoveBlockInBlockNodeWithInlineContent() {
69 '<h1><ins><div>Not allowed!</div></ins></h1>',
70 '<h1><ins>Not allowed!</ins></h1>'
74 function testNestedChameleonRemoveBlockInNodeWithInlineContent() {
76 '<h1><ins><del><div>Not allowed!</div></del></ins></h1>',
77 '<h1><ins><del>Not allowed!</del></ins></h1>'
81 function testNestedChameleonPreserveBlockInBlock() {
83 '<div><ins><del><div>Allowed!</div></del></ins></div>'
87 function testChameleonEscapeInvalidBlockInInline() {
88 $this->config
->set('Core.EscapeInvalidChildren', true);
89 $this->assertResult( // alt config
90 '<span><ins><div>Not allowed!</div></ins></span>',
91 '<span><ins><div>Not allowed!</div></ins></span>'
95 function testExclusionsIntegration() {
98 '<a><span><a>Not allowed</a></span></a>',
99 '<a><span></span></a>'
103 function testPreserveInlineNodeInInlineRootNode() {
104 $this->config
->set('HTML.Parent', 'span');
105 $this->assertResult('<b>Bold</b>');
108 function testRemoveBlockNodeInInlineRootNode() {
109 $this->config
->set('HTML.Parent', 'span');
110 $this->assertResult('<div>Reject</div>', 'Reject');
113 function testInvalidParentError() {
114 // test fallback to div
115 $this->config
->set('HTML.Parent', 'obviously-impossible');
116 $this->config
->set('Cache.DefinitionImpl', null);
117 $this->expectError('Cannot use unrecognized element as parent');
118 $this->assertResult('<div>Accept</div>');
121 function testCascadingRemovalOfNodesMissingRequiredChildren() {
122 $this->assertResult('<table><tr></tr></table>', '');
125 function testCascadingRemovalSpecialCaseCannotScrollOneBack() {
126 $this->assertResult('<table><tr></tr><tr></tr></table>', '');
129 function testLotsOfCascadingRemovalOfNodes() {
130 $this->assertResult('<table><tbody><tr></tr><tr></tr></tbody><tr></tr><tr></tr></table>', '');
133 function testAdjacentRemovalOfNodeMissingRequiredChildren() {
134 $this->assertResult('<table></table><table></table>', '');
137 function testStrictBlockquoteInHTML401() {
138 $this->config
->set('HTML.Doctype', 'HTML 4.01 Strict');
139 $this->assertResult('<blockquote>text</blockquote>', '<blockquote><p>text</p></blockquote>');
142 function testDisabledExcludes() {
143 $this->config
->set('Core.DisableExcludes', true);
144 $this->assertResult('<pre><font><font></font></font></pre>');
149 // vim: et sw=4 sts=4