diff options
author | Mario Vavti <mario@mariovavti.com> | 2017-05-31 09:56:35 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-05-31 09:56:35 +0200 |
commit | 47d55694a4c84b6c12c0db61a69bcac8b671b20e (patch) | |
tree | b15e96f4ea67e2214a66a9d28dafaf53d25b98ec /library/HTMLPurifier/Injector/RemoveEmpty.php | |
parent | 087f9784e3c5a860ed2b86e7f9e8e9f312038546 (diff) | |
parent | f0e615dee529e031663576286345141ad2996974 (diff) | |
download | volse-hubzilla-2.4.tar.gz volse-hubzilla-2.4.tar.bz2 volse-hubzilla-2.4.zip |
Merge branch '2.4RC'2.4
Diffstat (limited to 'library/HTMLPurifier/Injector/RemoveEmpty.php')
-rw-r--r-- | library/HTMLPurifier/Injector/RemoveEmpty.php | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/library/HTMLPurifier/Injector/RemoveEmpty.php b/library/HTMLPurifier/Injector/RemoveEmpty.php deleted file mode 100644 index cd885722e..000000000 --- a/library/HTMLPurifier/Injector/RemoveEmpty.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php - -class HTMLPurifier_Injector_RemoveEmpty extends HTMLPurifier_Injector -{ - /** - * @type HTMLPurifier_Context - */ - private $context; - - /** - * @type HTMLPurifier_Config - */ - private $config; - - /** - * @type HTMLPurifier_AttrValidator - */ - private $attrValidator; - - /** - * @type bool - */ - private $removeNbsp; - - /** - * @type bool - */ - private $removeNbspExceptions; - - /** - * @type array - * TODO: make me configurable - */ - private $_exclude = array('colgroup' => 1, 'th' => 1, 'td' => 1, 'iframe' => 1); - - /** - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return void - */ - public function prepare($config, $context) - { - parent::prepare($config, $context); - $this->config = $config; - $this->context = $context; - $this->removeNbsp = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp'); - $this->removeNbspExceptions = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions'); - $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)) { - if (isset($this->_exclude[$token->name])) { - return; - } - $this->attrValidator->validateToken($token, $this->config, $this->context); - $token->armor['ValidateAttributes'] = true; - 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; - } - } -} - -// vim: et sw=4 sts=4 |