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

[1.2.0] Allow configuration directives to permit null values. ConfigDoc updated accordingly.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@521 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-11-12 02:59:36 +00:00
parent ad934540da
commit 926b94bdd3
7 changed files with 99 additions and 16 deletions

View File

@@ -231,6 +231,17 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
$this->swallowErrors();
// define a directive that allows null
HTMLPurifier_ConfigSchema::define(
'Core', 'Foobaz', null, 'string/null',
'Nulls are allowed if you add on /null, cool huh?'
);
$this->assertNoErrors();
$this->swallowErrors();
// define a directive with bad characters
HTMLPurifier_ConfigSchema::define(
'Core', 'Core.Attr', 10, 'int',
@@ -258,7 +269,11 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
}
function assertInvalid($var, $type) {
$this->assertIdentical($this->our_copy->validate($var, $type), null);
$this->assertTrue(
$this->our_copy->isError(
$this->our_copy->validate($var, $type)
)
);
}
function testValidate() {
@@ -271,6 +286,7 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
$this->assertValid(0, 'bool', false);
$this->assertValid(1, 'bool', true);
$this->assertInvalid(34, 'bool');
$this->assertInvalid(null, 'bool');
$this->assertValid(array('1', '2', '3'), 'list');
$this->assertValid(array('1' => true, '2' => true), 'lookup');
$this->assertValid(array('1', '2'), 'lookup', array('1' => true, '2' => true));
@@ -281,6 +297,22 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
}
function testValidate_null() {
$this->assertTrue(
$this->our_copy->isError(
$this->our_copy->validate(null, 'string', false)
)
);
$this->assertFalse(
$this->our_copy->isError(
$this->our_copy->validate(null, 'string', true)
)
);
}
function assertMungeFilename($oldname, $newname) {
$this->assertIdentical(
$this->our_copy->mungeFilename($oldname),