1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-10-23 09:36:19 +02:00

Release 2.0.1, merged in 1181 to HEAD.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1255 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-06-27 14:30:45 +00:00
parent 42858ad594
commit 495164e938
326 changed files with 3025 additions and 826 deletions

View File

@@ -0,0 +1,253 @@
<?php
require_once 'HTMLPurifier/InjectorHarness.php';
require_once 'HTMLPurifier/Injector/AutoParagraph.php';
class HTMLPurifier_Injector_AutoParagraphTest extends HTMLPurifier_InjectorHarness
{
function setup() {
parent::setup();
$this->config = array('AutoFormat.AutoParagraph' => true);
}
function test() {
$this->assertResult(
'Foobar',
'<p>Foobar</p>'
);
$this->assertResult(
'Par 1
Par 1 still',
'<p>Par 1
Par 1 still</p>'
);
$this->assertResult(
'Par1
Par2',
'<p>Par1</p><p>Par2</p>'
);
$this->assertResult(
'Par1
Par2',
'<p>Par1</p><p>Par2</p>'
);
$this->assertResult(
'<b>Par1</b>
<i>Par2</i>',
'<p><b>Par1</b></p><p><i>Par2</i></p>'
);
$this->assertResult(
'<b>Par1
Par2</b>',
'<p><b>Par1
Par2</b></p>'
);
$this->assertResult(
'Par1<p>Par2</p>',
'<p>Par1</p><p>Par2</p>'
);
$this->assertResult(
'<b>Par1',
'<p><b>Par1</b></p>'
);
$this->assertResult(
'<pre>Par1
Par1</pre>'
);
$this->assertResult(
'Par1
',
'<p>Par1</p>'
);
$this->assertResult(
'Par1
<div>Par2</div>
Par3',
'<p>Par1</p><div>Par2</div><p>Par3</p>'
);
$this->assertResult(
'Par<b>1</b>',
'<p>Par<b>1</b></p>'
);
$this->assertResult(
'
Par',
'<p>Par</p>'
);
$this->assertResult(
'
Par
',
'<p>Par</p>'
);
$this->assertResult(
'<div>Par1
Par2</div>',
'<div><p>Par1</p><p>Par2</p></div>'
);
$this->assertResult(
'<div><b>Par1</b>
Par2</div>',
'<div><p><b>Par1</b></p><p>Par2</p></div>'
);
$this->assertResult('<div>Par1</div>');
$this->assertResult(
'<div><b>Par1</b>
<i>Par2</i></div>',
'<div><p><b>Par1</b></p><p><i>Par2</i></p></div>'
);
$this->assertResult(
'<pre><b>Par1</b>
<i>Par2</i></pre>',
true
);
$this->assertResult(
'<div><p>Foo
Bar</p></div>',
'<div><p>Foo</p><p>Bar</p></div>'
);
$this->assertResult(
'<div><p><b>Foo</b>
<i>Bar</i></p></div>',
'<div><p><b>Foo</b></p><p><i>Bar</i></p></div>'
);
$this->assertResult(
'<div><b>Foo</b></div>',
'<div><b>Foo</b></div>'
);
$this->assertResult(
'<blockquote>Par1
Par2</blockquote>',
'<blockquote><p>Par1</p><p>Par2</p></blockquote>'
);
$this->assertResult(
'<ul><li>Foo</li>
<li>Bar</li></ul>', true
);
$this->assertResult(
'<div>
Bar
</div>',
'<div><p>Bar</p></div>'
);
$this->assertResult(
'<b>Par1</b>a
Par2',
'<p><b>Par1</b>a</p><p>Par2</p>'
);
$this->assertResult(
'Par1
Par2</p>',
'<p>Par1</p><p>Par2</p>'
);
$this->assertResult(
'Par1
Par2</div>',
'<p>Par1</p><p>Par2</p>'
);
$this->assertResult(
'<div>
Par1
</div>', true
);
$this->assertResult(
'<div>Par1
<div>Par2</div></div>',
'<div><p>Par1</p><div>Par2</div></div>'
);
$this->assertResult(
'<div>Par1
<div>Par2</div></div>',
'<div><p>Par1
</p><div>Par2</div></div>'
);
$this->assertResult(
'Par1
<div>Par2</div>',
'<p>Par1
</p><div>Par2</div>'
);
$this->assertResult(
'Par1
<b>Par2</b>',
'<p>Par1</p><p><b>Par2</b></p>'
);
}
function testInlineRootNode() {
$this->assertResult(
'Par
Par2',
true,
array('AutoFormat.AutoParagraph' => true, 'HTML.Parent' => 'span')
);
}
}

View File

@@ -0,0 +1,38 @@
<?php
require_once 'HTMLPurifier/InjectorHarness.php';
require_once 'HTMLPurifier/Injector/Linkify.php';
class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
{
function setup() {
parent::setup();
$this->config = array('AutoFormat.Linkify' => true);
}
function testLinkify() {
$this->assertResult(
'http://example.com',
'<a href="http://example.com">http://example.com</a>'
);
$this->assertResult(
'<b>http://example.com</b>',
'<b><a href="http://example.com">http://example.com</a></b>'
);
$this->assertResult(
'This URL http://example.com is what you need',
'This URL <a href="http://example.com">http://example.com</a> is what you need'
);
$this->assertResult(
'<a>http://example.com/</a>'
);
}
}

View File

@@ -0,0 +1,42 @@
<?php
require_once 'HTMLPurifier/InjectorHarness.php';
require_once 'HTMLPurifier/Injector/PurifierLinkify.php';
class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHarness
{
function setup() {
parent::setup();
$this->config = array(
'AutoFormat.PurifierLinkify' => true,
'AutoFormatParam.PurifierLinkifyDocURL' => '#%s'
);
}
function testLinkify() {
$this->assertResult('Foobar');
$this->assertResult('20% off!');
$this->assertResult('%Core namespace (not recognized)');
$this->assertResult(
'%Namespace.Directive',
'<a href="#Namespace.Directive">%Namespace.Directive</a>'
);
$this->assertResult(
'This %Namespace.Directive thing',
'This <a href="#Namespace.Directive">%Namespace.Directive</a> thing'
);
$this->assertResult(
'<div>This %Namespace.Directive thing</div>',
'<div>This <a href="#Namespace.Directive">%Namespace.Directive</a> thing</div>'
);
$this->assertResult(
'<a>%Namespace.Directive</a>'
);
}
}