mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 15:28:40 +00:00
[1.6.1] Invert HTMLModuleManager->addModule() processing order to check prefixes first and then the literal module
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@971 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
d6c4473a12
commit
c0b38bab85
2
NEWS
2
NEWS
@ -16,6 +16,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
a non-alphanumeric character. This means that certain emoticons
|
||||
are now preserved.
|
||||
- Possibly fatal bug with __autoload() fixed in module manager
|
||||
- Invert HTMLModuleManager->addModule() processing order to check
|
||||
prefixes first and then the literal module
|
||||
|
||||
1.6.0, released 2007-04-01
|
||||
! Support for most common deprecated attributes via transformations:
|
||||
|
@ -208,20 +208,33 @@ class HTMLPurifier_HTMLModuleManager
|
||||
* subclass of HTMLPurifier_HTMLModule.
|
||||
* @note This function will not call autoload, you must instantiate
|
||||
* (and thus invoke) autoload outside the method.
|
||||
* @note If a string is passed as a module name, different variants
|
||||
* will be tested in this order:
|
||||
* - Check for HTMLPurifier_HTMLModule_$name
|
||||
* - Check all prefixes with $name in order they were added
|
||||
* - Check for literal object name
|
||||
* - Throw fatal error
|
||||
* If your object name collides with an internal class, specify
|
||||
* your module manually.
|
||||
*/
|
||||
function addModule($module) {
|
||||
if (is_string($module)) {
|
||||
$original_module = $module;
|
||||
if (!class_exists($module, false)) {
|
||||
foreach ($this->prefixes as $prefix) {
|
||||
$module = $prefix . $original_module;
|
||||
if (class_exists($module)) break;
|
||||
$ok = false;
|
||||
foreach ($this->prefixes as $prefix) {
|
||||
$module = $prefix . $original_module;
|
||||
if (class_exists($module)) {
|
||||
$ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!class_exists($module, false)) {
|
||||
trigger_error($original_module . ' module does not exist',
|
||||
E_USER_ERROR);
|
||||
return;
|
||||
if (!$ok) {
|
||||
$module = $original_module;
|
||||
if (!class_exists($module, false)) {
|
||||
trigger_error($original_module . ' module does not exist',
|
||||
E_USER_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
$module = new $module();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user