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

Factor out definitions to a ['child'] so that we could assign the ['attr'] definitions separately.

Also, added AttrDef/EnumTest.php

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@127 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-07-30 00:54:38 +00:00
parent 4c737ab430
commit f8eaedb500
8 changed files with 119 additions and 69 deletions

View File

@@ -39,8 +39,8 @@ class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
// $j is index of end token
// have DTD child def validate children
$element_def = $this->definition->info[$tokens[$i]->name];
$result = $element_def->child_def->validateChildren($child_tokens);
$child_def = $this->definition->info['child'][$tokens[$i]->name];
$result = $child_def->validateChildren($child_tokens);
// process result
if ($result === true) {

View File

@@ -23,10 +23,10 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
$result[] = $token;
continue;
}
$info = $this->definition->info[$token->name]; // assumption but valid
$info = $this->definition->info['child'][$token->name]; // assumption but valid
// test if it claims to be a start tag but is empty
if ($info->child_def->type == 'empty' &&
if ($info->type == 'empty' &&
$token->type == 'start' ) {
$result[] = new HTMLPurifier_Token_Empty($token->name,
@@ -35,7 +35,7 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
}
// test if it claims to be empty but really is a start tag
if ($info->child_def->type != 'empty' &&
if ($info->type != 'empty' &&
$token->type == 'empty' ) {
$result[] = new HTMLPurifier_Token_Start($token->name,

View File

@@ -19,7 +19,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements extends HTMLPurifier_Strategy
$result = array();
foreach($tokens as $token) {
if (!empty( $token->is_tag )) {
if (!isset($this->definition->info[$token->name])) {
if (!isset($this->definition->info['child'][$token->name])) {
// invalid tag, generate HTML and insert in
$token = new HTMLPurifier_Token_Text(
$this->generator->generateFromToken($token)