2006-09-01 17:56:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier.php';
|
|
|
|
|
|
|
|
// integration test
|
|
|
|
|
|
|
|
class HTMLPurifier_Test extends UnitTestCase
|
|
|
|
{
|
|
|
|
var $purifier;
|
|
|
|
|
2006-09-04 23:01:47 +00:00
|
|
|
function assertPurification($input, $expect = null) {
|
|
|
|
if ($expect === null) $expect = $input;
|
2006-09-01 17:56:55 +00:00
|
|
|
$result = $this->purifier->purify($input);
|
|
|
|
$this->assertIdentical($expect, $result);
|
|
|
|
}
|
|
|
|
|
2006-11-22 18:17:39 +00:00
|
|
|
function testNull() {
|
|
|
|
$this->purifier = new HTMLPurifier();
|
|
|
|
$this->assertPurification("Null byte\0", "Null byte");
|
|
|
|
}
|
|
|
|
|
|
|
|
function testStrict() {
|
2006-09-01 17:56:55 +00:00
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2006-11-22 18:17:39 +00:00
|
|
|
$config->set('HTML', 'Strict', true);
|
2006-09-01 17:56:55 +00:00
|
|
|
$this->purifier = new HTMLPurifier($config);
|
2006-11-22 18:17:39 +00:00
|
|
|
|
|
|
|
$this->assertPurification(
|
|
|
|
'<u>Illegal underline</u>',
|
|
|
|
'Illegal underline'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertPurification(
|
|
|
|
'<blockquote>Illegal contents</blockquote>',
|
2006-11-23 03:23:35 +00:00
|
|
|
'<blockquote><p>Illegal contents</p></blockquote>'
|
2006-11-22 18:17:39 +00:00
|
|
|
);
|
|
|
|
|
2006-09-01 17:56:55 +00:00
|
|
|
}
|
2006-11-22 18:17:39 +00:00
|
|
|
|
2006-09-01 17:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|