mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-05 21:57:26 +02:00
[3.1.0] Implement more validators, add in missing DEFAULTs for many tests.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1626 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -9,9 +9,18 @@ class HTMLPurifier_ConfigSchema_Validator
|
||||
protected $interchange;
|
||||
|
||||
/**
|
||||
* Volatile context variables to provide a fluent interface.
|
||||
* Context-stack to provide easy to read error messages.
|
||||
*/
|
||||
protected $context = array(), $obj, $member;
|
||||
protected $context = array();
|
||||
|
||||
/**
|
||||
* HTMLPurifier_VarParser to test variable types.
|
||||
*/
|
||||
protected $parser;
|
||||
|
||||
public function __construct() {
|
||||
$this->parser = new HTMLPurifier_VarParser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a fully-formed interchange object. Throws an
|
||||
@@ -38,17 +47,6 @@ class HTMLPurifier_ConfigSchema_Validator
|
||||
array_pop($this->context);
|
||||
}
|
||||
|
||||
public function validateDirective($d) {
|
||||
$this->context[] = "directive '{$d->id}'";
|
||||
$this->validateId($d->id);
|
||||
$this->with($d, 'description')
|
||||
->assertNotEmpty();
|
||||
if (!isset(HTMLPurifier_VarParser::$types[$d->type])) {
|
||||
$this->error('type', 'is invalid');
|
||||
}
|
||||
array_pop($this->context);
|
||||
}
|
||||
|
||||
public function validateId($id) {
|
||||
$this->context[] = "id '$id'";
|
||||
if (!isset($this->interchange->namespaces[$id->namespace])) {
|
||||
@@ -63,6 +61,21 @@ class HTMLPurifier_ConfigSchema_Validator
|
||||
array_pop($this->context);
|
||||
}
|
||||
|
||||
public function validateDirective($d) {
|
||||
$this->context[] = "directive '{$d->id}'";
|
||||
$this->validateId($d->id);
|
||||
$this->with($d, 'description')
|
||||
->assertNotEmpty();
|
||||
$this->with($d, 'type')
|
||||
->assertNotEmpty();
|
||||
if (!isset(HTMLPurifier_VarParser::$types[$d->type])) {
|
||||
$this->error('type', 'is invalid');
|
||||
}
|
||||
$this->parser->parse($d->default, $d->type, $d->typeAllowsNull);
|
||||
|
||||
array_pop($this->context);
|
||||
}
|
||||
|
||||
// protected helper functions
|
||||
|
||||
protected function with($obj, $member) {
|
||||
|
Reference in New Issue
Block a user