mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 19:30:21 +02:00
Increase test coverage, and modify handleEnd behavior to only see correct tokens.
Previously, handleEnd was called for any end tag, except ones that were obviously spurious because there were no parent tags. Now, it is only called for end tags that are "approved." If an injector operates on the end tag, we automatically punt. There may be some optimizations that could be made to this procedure, but for now it's much more consistent. Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
@@ -274,20 +274,23 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
|
||||
$reprocess = true;
|
||||
continue;
|
||||
}
|
||||
foreach ($this->injectors as $i => $injector) {
|
||||
if (isset($token->skip[$i])) continue;
|
||||
if ($token->rewind !== null && $token->rewind !== $i) continue;
|
||||
$injector->handleEnd($token);
|
||||
$this->processToken($token, $i);
|
||||
$reprocess = true;
|
||||
break;
|
||||
}
|
||||
if ($reprocess) continue;
|
||||
|
||||
// first, check for the simplest case: everything closes neatly
|
||||
// first, check for the simplest case: everything closes neatly.
|
||||
// Eventually, everything passes through here; if there are problems
|
||||
// we modify the input stream accordingly and then punt, so that
|
||||
// the tokens get processed again.
|
||||
$current_parent = array_pop($this->stack);
|
||||
if ($current_parent->name == $token->name) {
|
||||
$token->start = $current_parent;
|
||||
foreach ($this->injectors as $i => $injector) {
|
||||
if (isset($token->skip[$i])) continue;
|
||||
if ($token->rewind !== null && $token->rewind !== $i) continue;
|
||||
$injector->handleEnd($token);
|
||||
$this->processToken($token, $i);
|
||||
$this->stack[] = $current_parent;
|
||||
$reprocess = true;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -343,6 +346,7 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
|
||||
$this->insertBefore($new_token);
|
||||
}
|
||||
$reprocess = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$context->destroy('CurrentNesting');
|
||||
|
Reference in New Issue
Block a user