mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 14:16:32 +02:00
Make the definition format much more logical. Begin migrating specification docs to their respective classes.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@133 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -38,8 +38,11 @@ class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
|
||||
// $i is index of start token
|
||||
// $j is index of end token
|
||||
|
||||
|
||||
// DEFINITION CALL
|
||||
$child_def = $this->definition->info[$tokens[$i]->name]->child;
|
||||
|
||||
// have DTD child def validate children
|
||||
$child_def = $this->definition->info['child'][$tokens[$i]->name];
|
||||
$result = $child_def->validateChildren($child_tokens);
|
||||
|
||||
// process result
|
||||
|
@@ -23,7 +23,9 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
|
||||
$result[] = $token;
|
||||
continue;
|
||||
}
|
||||
$info = $this->definition->info['child'][$token->name]; // assumption but valid
|
||||
|
||||
// DEFINITION CALL
|
||||
$info = $this->definition->info[$token->name]->child;
|
||||
|
||||
// test if it claims to be a start tag but is empty
|
||||
if ($info->type == 'empty' &&
|
||||
|
@@ -4,6 +4,13 @@ require_once 'HTMLPurifier/Strategy.php';
|
||||
require_once 'HTMLPurifier/Definition.php';
|
||||
require_once 'HTMLPurifier/Generator.php';
|
||||
|
||||
/**
|
||||
* Removes all unrecognized tags from the list of tokens.
|
||||
*
|
||||
* This strategy iterates through all the tokens and removes unrecognized
|
||||
* tokens.
|
||||
*/
|
||||
|
||||
class HTMLPurifier_Strategy_RemoveForeignElements extends HTMLPurifier_Strategy
|
||||
{
|
||||
|
||||
@@ -19,7 +26,8 @@ class HTMLPurifier_Strategy_RemoveForeignElements extends HTMLPurifier_Strategy
|
||||
$result = array();
|
||||
foreach($tokens as $token) {
|
||||
if (!empty( $token->is_tag )) {
|
||||
if (!isset($this->definition->info['child'][$token->name])) {
|
||||
// DEFINITION CALL
|
||||
if (!isset($this->definition->info[$token->name])) {
|
||||
// invalid tag, generate HTML and insert in
|
||||
$token = new HTMLPurifier_Token_Text(
|
||||
$this->generator->generateFromToken($token)
|
||||
|
@@ -15,13 +15,14 @@ class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
|
||||
|
||||
function execute($tokens) {
|
||||
$accumulator = new HTMLPurifier_IDAccumulator();
|
||||
$d_defs = $this->definition->info['attr']['*'];
|
||||
$d_defs = $this->definition->info_global_attr;
|
||||
foreach ($tokens as $key => $token) {
|
||||
if ($token->type !== 'start' && $token->type !== 'end') continue;
|
||||
$name = $token->name;
|
||||
|
||||
// DEFINITION CALL
|
||||
$defs = $this->definition->info[$token->name]->attr;
|
||||
|
||||
$attr = $token->attributes;
|
||||
$defs = isset($this->definition->info['attr'][$name]) ?
|
||||
$this->definition->attr[$name] : array();
|
||||
$changed = false;
|
||||
foreach ($attr as $attr_key => $value) {
|
||||
if ( isset($defs[$attr_key]) ) {
|
||||
|
Reference in New Issue
Block a user