diff --git a/NEWS b/NEWS index ee0511cc..cfcfc97f 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier - Fix bug with non lower-case color names in HTML - Fix bug where data URI validation doesn't remove temporary files. Thanks Javier MarĂ­n Ros for reporting. +- Don't remove certain empty tags on RemoveEmpty. 4.4.0, released 2012-01-18 # Removed PEARSax3 handler. diff --git a/library/HTMLPurifier/Injector/RemoveEmpty.php b/library/HTMLPurifier/Injector/RemoveEmpty.php index 638bfca0..423f079e 100644 --- a/library/HTMLPurifier/Injector/RemoveEmpty.php +++ b/library/HTMLPurifier/Injector/RemoveEmpty.php @@ -5,6 +5,9 @@ class HTMLPurifier_Injector_RemoveEmpty extends HTMLPurifier_Injector private $context, $config, $attrValidator, $removeNbsp, $removeNbspExceptions; + // TODO: make me configurable + private $_exclude = array('colgroup' => 1, 'th' => 1, 'td' => 1, 'iframe' => 1); + public function prepare($config, $context) { parent::prepare($config, $context); $this->config = $config; @@ -30,7 +33,7 @@ class HTMLPurifier_Injector_RemoveEmpty extends HTMLPurifier_Injector break; } if (!$next || ($next instanceof HTMLPurifier_Token_End && $next->name == $token->name)) { - if ($token->name == 'colgroup') return; + 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;