diff --git a/NEWS b/NEWS index af32f72f..5906e9db 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier prefixes first and then the literal module - Empty strings get converted to empty arrays instead of arrays with an empty string in them. +- Merging in attribute lists now works. . Demo script removed: it has been added to the website's repository . Basic.php script modified to work out of the box . Refactor AttrTransform classes to reduce duplication diff --git a/library/HTMLPurifier/ElementDef.php b/library/HTMLPurifier/ElementDef.php index 21bc5f36..73c94abe 100644 --- a/library/HTMLPurifier/ElementDef.php +++ b/library/HTMLPurifier/ElementDef.php @@ -95,7 +95,7 @@ class HTMLPurifier_ElementDef // later keys takes precedence foreach($def->attr as $k => $v) { - if ($k == 0) { + if ($k === 0) { // merge in the includes // sorry, no way to override an include foreach ($v as $v2) { diff --git a/library/HTMLPurifier/HTMLModuleManager.php b/library/HTMLPurifier/HTMLModuleManager.php index 8860f68c..81ef13a5 100644 --- a/library/HTMLPurifier/HTMLModuleManager.php +++ b/library/HTMLPurifier/HTMLModuleManager.php @@ -225,14 +225,14 @@ class HTMLPurifier_HTMLModuleManager $ok = false; foreach ($this->prefixes as $prefix) { $module = $prefix . $original_module; - if (class_exists($module)) { + if ($this->_classExists($module)) { $ok = true; break; } } if (!$ok) { $module = $original_module; - if (!class_exists($module, false)) { + if (!$this->_classExists($module)) { trigger_error($original_module . ' module does not exist', E_USER_ERROR); return; @@ -247,6 +247,23 @@ class HTMLPurifier_HTMLModuleManager } } + /** + * Safely tests for class existence without invoking __autoload in PHP5 + * @param $name String class name to test + * @private + */ + function _classExists($name) { + static $is_php_4 = null; + if ($is_php_4 === null) { + $is_php_4 = version_compare(PHP_VERSION, '5', '<'); + } + if ($is_php_4) { + return class_exists($name); + } else { + return class_exists($name, false); + } + } + /** * Makes a collection active, while also making it valid if not * already done so. See $activeModules for the semantics of "active". @@ -508,7 +525,8 @@ class HTMLPurifier_HTMLModuleManager $elements = array(); foreach ($this->activeModules as $module) { - foreach ($module->elements as $name) { + foreach ($module->info as $name => $v) { + if (isset($elements[$name])) continue; $elements[$name] = $this->getElement($name, $config); } }