mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-10 09:16:20 +02:00
- Rename Duplicate to Unique, as the name of validator indicates what we want the input to be
- Enable flush to work when includes are renamed git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1597 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@ -133,6 +133,7 @@ require 'HTMLPurifier/ConfigSchema/StringHashReverseAdapter.php';
|
|||||||
require 'HTMLPurifier/ConfigSchema/Validator.php';
|
require 'HTMLPurifier/ConfigSchema/Validator.php';
|
||||||
require 'HTMLPurifier/ConfigSchema/Validator/Alnum.php';
|
require 'HTMLPurifier/ConfigSchema/Validator/Alnum.php';
|
||||||
require 'HTMLPurifier/ConfigSchema/Validator/Exists.php';
|
require 'HTMLPurifier/ConfigSchema/Validator/Exists.php';
|
||||||
|
require 'HTMLPurifier/ConfigSchema/Validator/Unique.php';
|
||||||
require 'HTMLPurifier/DefinitionCache/Decorator.php';
|
require 'HTMLPurifier/DefinitionCache/Decorator.php';
|
||||||
require 'HTMLPurifier/DefinitionCache/Null.php';
|
require 'HTMLPurifier/DefinitionCache/Null.php';
|
||||||
require 'HTMLPurifier/DefinitionCache/Serializer.php';
|
require 'HTMLPurifier/DefinitionCache/Serializer.php';
|
||||||
|
@ -158,22 +158,6 @@ class HTMLPurifier_ConfigSchema {
|
|||||||
* @param $description Description of the namespace
|
* @param $description Description of the namespace
|
||||||
*/
|
*/
|
||||||
public function addNamespace($namespace, $description) {
|
public function addNamespace($namespace, $description) {
|
||||||
if (HTMLPURIFIER_SCHEMA_STRICT) {
|
|
||||||
if (isset($this->info[$namespace])) {
|
|
||||||
trigger_error('Cannot redefine namespace', E_USER_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!ctype_alnum($namespace)) {
|
|
||||||
trigger_error('Namespace name must be alphanumeric',
|
|
||||||
E_USER_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (empty($description)) {
|
|
||||||
trigger_error('Description must be non-empty',
|
|
||||||
E_USER_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->info[$namespace] = array();
|
$this->info[$namespace] = array();
|
||||||
$this->info_namespace[$namespace] = new HTMLPurifier_ConfigDef_Namespace();
|
$this->info_namespace[$namespace] = new HTMLPurifier_ConfigDef_Namespace();
|
||||||
$this->info_namespace[$namespace]->description = $description;
|
$this->info_namespace[$namespace]->description = $description;
|
||||||
|
@ -60,7 +60,7 @@ class HTMLPurifier_ConfigSchema_Interchange
|
|||||||
|
|
||||||
// Common validators
|
// Common validators
|
||||||
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Exists('ID'));
|
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Exists('ID'));
|
||||||
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Duplicate());
|
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Unique());
|
||||||
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Exists('DESCRIPTION'));
|
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Exists('DESCRIPTION'));
|
||||||
|
|
||||||
// Namespace validators
|
// Namespace validators
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Although this tests both possible values, in practice the ID
|
* Although this tests both possible values, in practice the ID
|
||||||
* will only be in one or the other. We do this to keep things simple.
|
* will only be in one or the other. We do this to keep things simple.
|
||||||
*/
|
*/
|
||||||
class HTMLPurifier_ConfigSchema_Validator_Duplicate extends HTMLPurifier_ConfigSchema_Validator
|
class HTMLPurifier_ConfigSchema_Validator_Unique extends HTMLPurifier_ConfigSchema_Validator
|
||||||
{
|
{
|
||||||
|
|
||||||
public function validate(&$arr, $interchange) {
|
public function validate(&$arr, $interchange) {
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class HTMLPurifier_ConfigSchema_Validator_DuplicateTest extends HTMLPurifier_ConfigSchema_ValidatorHarness
|
class HTMLPurifier_ConfigSchema_Validator_UniqueTest extends HTMLPurifier_ConfigSchema_ValidatorHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
public function setup() {
|
public function setup() {
|
||||||
parent::setup();
|
parent::setup();
|
||||||
$this->validator = new HTMLPurifier_ConfigSchema_Validator_Duplicate();
|
$this->validator = new HTMLPurifier_ConfigSchema_Validator_Unique();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidateNamespace() {
|
public function testValidateNamespace() {
|
@ -19,15 +19,6 @@ class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness
|
|||||||
$this->assertIdentical($this->schema->info_namespace, array(
|
$this->assertIdentical($this->schema->info_namespace, array(
|
||||||
'http' => new HTMLPurifier_ConfigDef_Namespace($d)
|
'http' => new HTMLPurifier_ConfigDef_Namespace($d)
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->expectError('Cannot redefine namespace');
|
|
||||||
$this->schema->addNamespace('http', 'It is used to serve webpages.');
|
|
||||||
|
|
||||||
$this->expectError('Namespace name must be alphanumeric');
|
|
||||||
$this->schema->addNamespace('ssh+http', 'This http is tunneled through SSH.');
|
|
||||||
|
|
||||||
$this->expectError('Description must be non-empty');
|
|
||||||
$this->schema->addNamespace('ftp', null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_define() {
|
function test_define() {
|
||||||
|
@ -57,6 +57,16 @@ if ($AC['disable-phpt'] && $AC['only-phpt']) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shell-script code is executed
|
||||||
|
|
||||||
|
if ($AC['flush']) {
|
||||||
|
if (SimpleReporter::inCli() && !$AC['xml']) {
|
||||||
|
passthru($AC['php'] . ' ../maintenance/flush.php');
|
||||||
|
} else {
|
||||||
|
shell_exec($AC['php'] . ' ../maintenance/flush.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// initialize and load HTML Purifier
|
// initialize and load HTML Purifier
|
||||||
// use ?standalone to load the alterative standalone stub
|
// use ?standalone to load the alterative standalone stub
|
||||||
if ($AC['standalone']) {
|
if ($AC['standalone']) {
|
||||||
@ -68,16 +78,6 @@ if ($AC['standalone']) {
|
|||||||
}
|
}
|
||||||
require 'HTMLPurifier/Harness.php';
|
require 'HTMLPurifier/Harness.php';
|
||||||
|
|
||||||
// Shell-script code is executed
|
|
||||||
|
|
||||||
if ($AC['flush']) {
|
|
||||||
if (SimpleReporter::inCli() && !$AC['xml']) {
|
|
||||||
passthru($AC['php'] . ' ../maintenance/flush.php');
|
|
||||||
} else {
|
|
||||||
shell_exec($AC['php'] . ' ../maintenance/flush.php');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now, userland code begins to be executed
|
// Now, userland code begins to be executed
|
||||||
|
|
||||||
// setup special DefinitionCacheFactory decorator
|
// setup special DefinitionCacheFactory decorator
|
||||||
|
Reference in New Issue
Block a user