mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-23 00:41:52 +00:00
22ef52a7f6
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1336 48356398-32a2-884e-a903-53898d9a118a
65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
|
|
require_once 'HTMLPurifier/Definition.php';
|
|
require_once 'HTMLPurifier/URIFilter.php';
|
|
|
|
require_once 'HTMLPurifier/URIFilter/DisableExternal.php';
|
|
require_once 'HTMLPurifier/URIFilter/DisableExternalResources.php';
|
|
require_once 'HTMLPurifier/URIFilter/HostBlacklist.php';
|
|
|
|
HTMLPurifier_ConfigSchema::define(
|
|
'URI', 'DefinitionID', null, 'string/null', '
|
|
<p>
|
|
Unique identifier for a custom-built URI definition. If you want
|
|
to add custom URIFilters, you must specify this value.
|
|
This directive has been available since 2.1.0.
|
|
</p>
|
|
');
|
|
|
|
HTMLPurifier_ConfigSchema::define(
|
|
'URI', 'DefinitionRev', 1, 'int', '
|
|
<p>
|
|
Revision identifier for your custom definition. See
|
|
%HTML.DefinitionRev for details. This directive has been available
|
|
since 2.1.0.
|
|
</p>
|
|
');
|
|
|
|
class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition
|
|
{
|
|
|
|
var $type = 'URI';
|
|
var $filters = array();
|
|
var $registeredFilters = array();
|
|
|
|
function HTMLPurifier_URIDefinition() {
|
|
$this->registerFilter(new HTMLPurifier_URIFilter_DisableExternal());
|
|
$this->registerFilter(new HTMLPurifier_URIFilter_DisableExternalResources());
|
|
$this->registerFilter(new HTMLPurifier_URIFilter_HostBlacklist());
|
|
}
|
|
|
|
function registerFilter($filter) {
|
|
$this->registeredFilters[$filter->name] = $filter;
|
|
}
|
|
|
|
function doSetup($config) {
|
|
foreach ($this->registeredFilters as $name => $filter) {
|
|
$conf = $config->get('URI', $name);
|
|
if ($conf !== false && $conf !== null) {
|
|
$this->filters[$name] = $filter;
|
|
}
|
|
}
|
|
foreach ($this->filters as $n => $x) $this->filters[$n]->prepare($config);
|
|
unset($this->registeredFilters);
|
|
}
|
|
|
|
function filter(&$uri, $config, &$context) {
|
|
foreach ($this->filters as $name => $x) {
|
|
$result = $this->filters[$name]->filter($uri, $config, $context);
|
|
if (!$result) return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
}
|