1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-30 19:00:10 +02:00
- Add tests for the atoms.
- Add Id validation for Directives

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1623 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-22 21:06:55 +00:00
parent 34ba0e408f
commit b8f00ace1a
4 changed files with 98 additions and 19 deletions

View File

@@ -30,7 +30,6 @@ class HTMLPurifier_ConfigSchema_Validator
public function validateNamespace($n) {
$this->context = "namespace '{$n->namespace}'";
$this->with($n, 'namespace')
->assertIsString()
->assertNotEmpty()
->assertAlnum();
$this->with($n, 'description')
@@ -40,12 +39,27 @@ class HTMLPurifier_ConfigSchema_Validator
public function validateDirective($d) {
$this->context = "directive '{$d->id}'";
$this->validateId($d->id);
}
public function validateId($id) {
$this->context = "id '$id'";
$this->with($id, 'namespace')
->assertNotEmpty()
->assertAlnum();
$this->with($id, 'directive')
->assertNotEmpty()
->assertAlnum();
}
// protected helper functions
protected function with($obj, $member) {
return new HTMLPurifier_ConfigSchema_ValidatorAtom($this->interchange, $this->context, $obj, $member);
return new HTMLPurifier_ConfigSchema_ValidatorAtom($this->context, $obj, $member);
}
protected function error($msg) {
throw new HTMLPurifier_ConfigSchema_Exception($msg . ' in ' . $this->context);
}
}