2006-07-24 02:41:06 +00:00
|
|
|
<?php
|
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarness
|
2006-07-24 02:41:06 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-10-01 21:55:13 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testEmptyInput() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult('');
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testWellFormedInput() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult('This is <b>bold text</b>.');
|
2007-05-27 23:12:17 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testUnclosedTagTerminatedByDocumentEnd() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>Unclosed tag, gasp!',
|
|
|
|
'<b>Unclosed tag, gasp!</b>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testUnclosedTagTerminatedByParentNodeEnd() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b><i>Bold and italic?</b>',
|
2008-12-20 18:06:00 +00:00
|
|
|
'<b><i>Bold and italic?</i></b><i></i>'
|
2006-10-01 21:55:13 +00:00
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testRemoveStrayClosingTag() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Unused end tags... recycle!</b>',
|
|
|
|
'Unused end tags... recycle!'
|
|
|
|
);
|
2007-05-27 23:12:17 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testConvertStartToEmpty() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<br style="clear:both;">',
|
|
|
|
'<br style="clear:both;" />'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testConvertEmptyToStart() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div style="clear:both;" />',
|
|
|
|
'<div style="clear:both;"></div>'
|
|
|
|
);
|
2007-05-27 23:12:17 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testAutoCloseParagraph() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<p>Paragraph 1<p>Paragraph 2',
|
|
|
|
'<p>Paragraph 1</p><p>Paragraph 2</p>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testAutoCloseParagraphInsideDiv() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><p>Paragraphs<p>In<p>A<p>Div</div>',
|
|
|
|
'<div><p>Paragraphs</p><p>In</p><p>A</p><p>Div</p></div>'
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testAutoCloseListItem() {
|
2006-10-01 21:55:13 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<ol><li>Item 1<li>Item 2</ol>',
|
|
|
|
'<ol><li>Item 1</li><li>Item 2</li></ol>'
|
|
|
|
);
|
2006-07-24 02:41:06 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function testAutoCloseColgroup() {
|
2007-06-24 02:59:06 +00:00
|
|
|
$this->assertResult(
|
2007-08-06 06:22:23 +00:00
|
|
|
'<table><colgroup><col /><tr></tr></table>',
|
|
|
|
'<table><colgroup><col /></colgroup><tr></tr></table>'
|
2007-06-24 02:59:06 +00:00
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-01-10 21:40:41 +00:00
|
|
|
function testAutoCloseMultiple() {
|
|
|
|
$this->assertResult(
|
2008-12-20 18:06:00 +00:00
|
|
|
'<b><span><div></div>asdf',
|
|
|
|
'<b><span></span></b><div><b></b></div><b>asdf</b>'
|
2008-01-10 21:40:41 +00:00
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-07-05 07:11:29 +00:00
|
|
|
function testUnrecognized() {
|
|
|
|
$this->assertResult(
|
|
|
|
'<asdf><foobar /><biddles>foo</asdf>',
|
|
|
|
'<asdf><foobar /><biddles>foo</biddles></asdf>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-02 00:52:06 +00:00
|
|
|
function testBlockquoteWithInline() {
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
|
2008-08-02 00:52:06 +00:00
|
|
|
$this->assertResult(
|
2008-12-06 07:28:20 +00:00
|
|
|
// This is actually invalid, but will be fixed by
|
2008-08-02 00:52:06 +00:00
|
|
|
// ChildDef_StrictBlockquote
|
|
|
|
'<blockquote>foo<b>bar</b></blockquote>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-12-20 18:06:00 +00:00
|
|
|
function testLongCarryOver() {
|
|
|
|
$this->assertResult(
|
|
|
|
'<b>asdf<div>asdf<i>df</i></div>asdf</b>',
|
|
|
|
'<b>asdf</b><div><b>asdf<i>df</i></b></div><b>asdf</b>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testInterleaved() {
|
|
|
|
$this->assertResult(
|
|
|
|
'<u>foo<i>bar</u>baz</i>',
|
|
|
|
'<u>foo<i>bar</i></u><i>baz</i>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-03-10 05:58:37 +00:00
|
|
|
function testNestedOl() {
|
|
|
|
$this->assertResult(
|
2010-05-18 03:22:51 +00:00
|
|
|
'<ol><ol><li>foo</li></ol></ol>',
|
|
|
|
'<ol><li><ol><li>foo</li></ol></li></ol>'
|
2010-03-10 05:58:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testNestedUl() {
|
|
|
|
$this->assertResult(
|
|
|
|
'<ul><ul></ul></ul>',
|
|
|
|
'<ul><li><ul></ul></li></ul>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testNestedOlWithStrangeEnding() {
|
|
|
|
$this->assertResult(
|
|
|
|
'<ol><li><ol><ol><li>foo</li></ol></li><li>foo</li></ol>',
|
|
|
|
'<ol><li><ol><li><ol><li>foo</li></ol></li><li>foo</li></ol></li></ol>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2006-07-24 02:41:06 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|