1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 03:10:09 +02:00

Refactor AttrTransform_Lang slightly by changing input output from token to attribute.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@163 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-08-05 02:16:28 +00:00
parent 8a23710405
commit 9d390fca56
4 changed files with 50 additions and 52 deletions

View File

@@ -31,13 +31,13 @@ class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
// DEFINITION CALL
$defs = $this->definition->info[$token->name]->attr;
$attr = $token->attributes;
// DEFINITION CALL
foreach ($this->definition->info_attr_transform as $transformer) {
$token = $transformer->transform($token);
$attr = $transformer->transform($attr);
}
$attr = $token->attributes;
$changed = false;
foreach ($attr as $attr_key => $value) {
// call the definition
@@ -55,20 +55,19 @@ class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
// put the results into effect
if ($result === false || $result === null) {
$changed = true;
unset($attr[$attr_key]);
} elseif (is_string($result)) {
// simple substitution
$changed = true;
$attr[$attr_key] = $result;
}
// we'd also want slightly more complicated substitution,
// although we're not sure how colliding attributes would
// resolve
}
if ($changed) {
$tokens[$key]->attributes = $attr;
}
// commit changes
// could interfere with flyweight implementation
$tokens[$key]->attributes = $attr;
}
return $tokens;
}