mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 03:10:09 +02:00
Generalize IDAccumulator into AttrContext. Modify tests and classes accordingly. Also, this allows us to make the validate() parameters uniform among all AttrDef subclasses.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@212 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -4,6 +4,7 @@ require_once 'HTMLPurifier/Strategy.php';
|
||||
require_once 'HTMLPurifier/Definition.php';
|
||||
require_once 'HTMLPurifier/IDAccumulator.php';
|
||||
require_once 'HTMLPurifier/ConfigDef.php';
|
||||
require_once 'HTMLPurifier/AttrContext.php';
|
||||
|
||||
HTMLPurifier_ConfigDef::define(
|
||||
'Attr', 'IDBlacklist', array(),
|
||||
@@ -27,11 +28,14 @@ class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
|
||||
// load default configuration object if none passed
|
||||
if (!$config) $config = HTMLPurifier_Config::createDefault();
|
||||
|
||||
// setup StrategyContext
|
||||
$context = new HTMLPurifier_AttrContext();
|
||||
|
||||
// setup ID accumulator and load it with blacklisted IDs
|
||||
// eventually, we'll have a dedicated context object to hold
|
||||
// all these accumulators and caches. For now, just an IDAccumulator
|
||||
$accumulator = new HTMLPurifier_IDAccumulator();
|
||||
$accumulator->load($config->get('Attr', 'IDBlacklist'));
|
||||
$context->id_accumulator = new HTMLPurifier_IDAccumulator();
|
||||
$context->id_accumulator->load($config->get('Attr', 'IDBlacklist'));
|
||||
|
||||
// create alias to global definition array, see also $defs
|
||||
// DEFINITION CALL
|
||||
@@ -84,14 +88,14 @@ class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
|
||||
} else {
|
||||
// validate according to the element's definition
|
||||
$result = $defs[$attr_key]->validate(
|
||||
$value, $config, $accumulator
|
||||
$value, $config, $context
|
||||
);
|
||||
}
|
||||
} elseif ( isset($d_defs[$attr_key]) ) {
|
||||
// there is a global definition defined, validate according
|
||||
// to the global definition
|
||||
$result = $d_defs[$attr_key]->validate(
|
||||
$value, $config, $accumulator
|
||||
$value, $config, $context
|
||||
);
|
||||
} else {
|
||||
// system never heard of the attribute? DELETE!
|
||||
|
Reference in New Issue
Block a user