mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-04 21:28:06 +02:00
[1.2.0]
- Partially finished migrating to new Context object (done in r485). - Created HTMLPurifier_Harness to assist with testing, ChildDefTest migrated to that framework. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@484 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -34,8 +34,7 @@ require_once 'HTMLPurifier/HTMLDefinition.php';
|
||||
class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
|
||||
{
|
||||
|
||||
function execute($tokens, $config) {
|
||||
|
||||
function execute($tokens, $config, &$context) {
|
||||
//####################################################################//
|
||||
// Pre-processing
|
||||
|
||||
@@ -49,6 +48,10 @@ class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
|
||||
array_unshift($tokens, new HTMLPurifier_Token_Start($parent_name));
|
||||
$tokens[] = new HTMLPurifier_Token_End($parent_name);
|
||||
|
||||
// setup the context variables
|
||||
$parent_type = 'unknown'; // reference var that we alter
|
||||
$context->register('ParentType', $parent_type);
|
||||
|
||||
//####################################################################//
|
||||
// Loop initialization
|
||||
|
||||
@@ -109,10 +112,10 @@ class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
|
||||
|
||||
// calculate context
|
||||
if (isset($parent_def)) {
|
||||
$context = $parent_def->type;
|
||||
$parent_type = $parent_def->type;
|
||||
} else {
|
||||
// generally found in specialized elements like UL
|
||||
$context = 'unknown';
|
||||
$parent_type = 'unknown';
|
||||
}
|
||||
|
||||
//################################################################//
|
||||
@@ -145,7 +148,7 @@ class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
|
||||
|
||||
// have DTD child def validate children
|
||||
$result = $child_def->validateChildren(
|
||||
$child_tokens, $config,$context);
|
||||
$child_tokens, $config, $context);
|
||||
|
||||
// determine whether or not this element has any exclusions
|
||||
$excludes = $def->excludes;
|
||||
@@ -247,6 +250,9 @@ class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
|
||||
array_shift($tokens);
|
||||
array_pop($tokens);
|
||||
|
||||
// remove context variables
|
||||
$context->destroy('ParentType');
|
||||
|
||||
//####################################################################//
|
||||
// Return
|
||||
|
||||
|
Reference in New Issue
Block a user