config = $config;
$this->context = $context;
$this->removeNbsp = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp');
$this->removeNbspExceptions = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions');
$this->exclude = $config->get('AutoFormat.RemoveEmpty.Predicate');
foreach ($this->exclude as $key => $attrs) {
if (!is_array($attrs)) {
// HACK, see HTMLPurifier/Printer/ConfigForm.php
$this->exclude[$key] = explode(';', $attrs);
}
}
$this->attrValidator = new HTMLPurifier_AttrValidator();
}
/**
* @param HTMLPurifier_Token $token
*/
public function handleElement(&$token)
{
if (!$token instanceof HTMLPurifier_Token_Start) {
return;
}
$next = false;
$deleted = 1; // the current tag
for ($i = count($this->inputZipper->back) - 1; $i >= 0; $i--, $deleted++) {
$next = $this->inputZipper->back[$i];
if ($next instanceof HTMLPurifier_Token_Text) {
if ($next->is_whitespace) {
continue;
}
if ($this->removeNbsp && !isset($this->removeNbspExceptions[$token->name])) {
$plain = str_replace("\xC2\xA0", "", $next->data);
$isWsOrNbsp = $plain === '' || ctype_space($plain);
if ($isWsOrNbsp) {
continue;
}
}
}
break;
}
if (!$next || ($next instanceof HTMLPurifier_Token_End && $next->name == $token->name)) {
$this->attrValidator->validateToken($token, $this->config, $this->context);
$token->armor['ValidateAttributes'] = true;
if (isset($this->exclude[$token->name])) {
$r = true;
foreach ($this->exclude[$token->name] as $elem) {
if (!isset($token->attr[$elem])) $r = false;
}
if ($r) return;
}
if (isset($token->attr['id']) || isset($token->attr['name'])) {
return;
}
$token = $deleted + 1;
for ($b = 0, $c = count($this->inputZipper->front); $b < $c; $b++) {
$prev = $this->inputZipper->front[$b];
if ($prev instanceof HTMLPurifier_Token_Text && $prev->is_whitespace) {
continue;
}
break;
}
// This is safe because we removed the token that triggered this.
$this->rewindOffset($b+$deleted);
return;
}
}
}__halt_compiler();----SIGNATURE:----ZslQv3hqg7OTpJiCyR5Om8SljVD5Ttfkk9zjEw7y4xnjmUgaD625kko09XhwKbQ8PH9YIq7+3lw1jKLq9BrRiVmLqKMmURslwYFOsxqNOjOyZAtqfgagT0r/p1zOeUE8NrJNi4+84HKlNHbMH5co4NMIlNe4PJM7rMLGYUZTTT7HEdabOG7hwJlOQDHgG1JSiCgqtMcLHGYo58bU5XkyoJ4y493DXq8hB7DL2W4NYfTQSSYtfP8H+YmauZ0JRJBz/J2Lx/VKGqWjMr8ybc6HrSeqKGO8D7zyekYQVPjiZw70+mpHDC8vaaEJJrsL7oUdM9mK5WkiDbTxlHR9OQOF3hdr1DJs9YZ+6kn7UkAgpCx45R5DIfpkbqraE5qd4J+/KgV24VQNtxFlGaWO9gJDbhpI5EtQlu7ZyyWJN4kbqZB3aEQV7OPionNy9hqWFZAdTom/l/BcR6DE3ugj3KonwHLu+ExUWlioYNYd75GwrpbNJ0Lc2FyVTYyNtjA8kXF7XqeapBYvAE/RA9LUH/yROMuG6HjgZyCSgGR/F6sXLphItn90te/u20GCc33fO7TBo9jLG8HJ+bkPv8eDOAjZD/VJX+CjWNZpvZfJt+TqGnP3H4qvDIhU22V10jwhhz+bg5k3BJfJzBg1JDIuMnJFbc8HrnUQWNjBJ2hNUAKv5cc=----ATTACHMENT:----MzIyMzE1MjUxOTYwNzU1NiA5NTc4MzI4ODYzNzIwNDY1IDgwNzM2ODkwNTA4MTA2MDM=