1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 19:30:21 +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:
Edward Z. Yang
2006-08-12 16:04:40 +00:00
parent 77f2833f36
commit a2880bdff2
15 changed files with 43 additions and 24 deletions

View File

@@ -12,12 +12,12 @@ require_once 'HTMLPurifier/IDAccumulator.php';
class HTMLPurifier_AttrDef_ID extends HTMLPurifier_AttrDef
{
function validate($id, $config, &$accumulator) {
function validate($id, $config, &$context) {
$id = trim($id); // trim it first
if ($id === '') return false;
if (isset($accumulator->ids[$id])) return false;
if (isset($context->id_accumulator->ids[$id])) return false;
// we purposely avoid using regex, hopefully this is faster
@@ -32,7 +32,7 @@ class HTMLPurifier_AttrDef_ID extends HTMLPurifier_AttrDef
$result = ($trim === '');
}
if ($result) $accumulator->add($id);
if ($result) $context->id_accumulator->add($id);
// if no change was made to the ID, return the result
// else, return the new id if stripping whitespace made it