0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 23:28:42 +00:00

[1.6.1] Fix bug (== v. ===) that caused merged in attribute definitions to be messed up

- Make our modified class_exists() check to work in both PHP 4 and 5
(todo: we need some unit tests for ElementDef)

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1023 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2007-05-05 20:04:34 +00:00
parent b1822bb04f
commit 6c08ca4c16
3 changed files with 23 additions and 4 deletions

1
NEWS
View File

@ -37,6 +37,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
prefixes first and then the literal module prefixes first and then the literal module
- Empty strings get converted to empty arrays instead of arrays with - Empty strings get converted to empty arrays instead of arrays with
an empty string in them. an empty string in them.
- Merging in attribute lists now works.
. Demo script removed: it has been added to the website's repository . Demo script removed: it has been added to the website's repository
. Basic.php script modified to work out of the box . Basic.php script modified to work out of the box
. Refactor AttrTransform classes to reduce duplication . Refactor AttrTransform classes to reduce duplication

View File

@ -95,7 +95,7 @@ class HTMLPurifier_ElementDef
// later keys takes precedence // later keys takes precedence
foreach($def->attr as $k => $v) { foreach($def->attr as $k => $v) {
if ($k == 0) { if ($k === 0) {
// merge in the includes // merge in the includes
// sorry, no way to override an include // sorry, no way to override an include
foreach ($v as $v2) { foreach ($v as $v2) {

View File

@ -225,14 +225,14 @@ class HTMLPurifier_HTMLModuleManager
$ok = false; $ok = false;
foreach ($this->prefixes as $prefix) { foreach ($this->prefixes as $prefix) {
$module = $prefix . $original_module; $module = $prefix . $original_module;
if (class_exists($module)) { if ($this->_classExists($module)) {
$ok = true; $ok = true;
break; break;
} }
} }
if (!$ok) { if (!$ok) {
$module = $original_module; $module = $original_module;
if (!class_exists($module, false)) { if (!$this->_classExists($module)) {
trigger_error($original_module . ' module does not exist', trigger_error($original_module . ' module does not exist',
E_USER_ERROR); E_USER_ERROR);
return; 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 * Makes a collection active, while also making it valid if not
* already done so. See $activeModules for the semantics of "active". * already done so. See $activeModules for the semantics of "active".
@ -508,7 +525,8 @@ class HTMLPurifier_HTMLModuleManager
$elements = array(); $elements = array();
foreach ($this->activeModules as $module) { 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); $elements[$name] = $this->getElement($name, $config);
} }
} }