1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-04 13:18:00 +02:00

Implement attribute transforms for required attributes. I can now confidently say that output will always be valid.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@256 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-08-14 23:11:28 +00:00
parent e770d994a7
commit 24c64dbbac
12 changed files with 229 additions and 37 deletions

View File

@@ -47,20 +47,20 @@ class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
// copy out attributes for easy manipulation
$attr = $token->attributes;
// do global transformations
// do global transformations (pre)
// ex. <ELEMENT lang="fr"> to <ELEMENT lang="fr" xml:lang="fr">
// DEFINITION CALL
foreach ($this->definition->info_attr_transform as $transform) {
$attr = $transform->transform($attr);
foreach ($this->definition->info_attr_transform_pre as $transform) {
$attr = $transform->transform($attr, $config);
}
// do local transformations only applicable to this element
// do local transformations only applicable to this element (pre)
// ex. <p align="right"> to <p style="text-align:right;">
// DEFINITION CALL
foreach ($this->definition->info[$token->name]->attr_transform
foreach ($this->definition->info[$token->name]->attr_transform_pre
as $transform
) {
$attr = $transform->transform($attr);
$attr = $transform->transform($attr, $config);
}
// create alias to this element's attribute definition array, see
@@ -115,6 +115,14 @@ class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
// others would prepend themselves).
}
// post transforms
foreach ($this->definition->info_attr_transform_post as $transform) {
$attr = $transform->transform($attr, $config);
}
foreach ($this->definition->info[$token->name]->attr_transform_post as $transform) {
$attr = $transform->transform($attr, $config);
}
// commit changes
// could interfere with flyweight implementation
$tokens[$key]->attributes = $attr;