mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-03-23 22:37:02 +00:00
Fix back-compat regressions. Also, compactify configuration code.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1771 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
14d934c7ca
commit
3c4346cb1e
@ -65,7 +65,7 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef
|
|||||||
}
|
}
|
||||||
// $font is a pure representation of the font name
|
// $font is a pure representation of the font name
|
||||||
|
|
||||||
if (ctype_alnum($font)) {
|
if (ctype_alnum($font) && $font !== '') {
|
||||||
// very simple font, allow it in unharmed
|
// very simple font, allow it in unharmed
|
||||||
$final .= $font . ', ';
|
$final .= $font . ', ';
|
||||||
continue;
|
continue;
|
||||||
|
@ -196,14 +196,16 @@ class HTMLPurifier_Config
|
|||||||
E_USER_WARNING);
|
E_USER_WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isset($this->def->info[$namespace][$key]->isAlias)) {
|
$def = $this->def->info[$namespace][$key];
|
||||||
|
|
||||||
|
if (isset($def->isAlias)) {
|
||||||
if ($from_alias) {
|
if ($from_alias) {
|
||||||
trigger_error('Double-aliases not allowed, please fix '.
|
trigger_error('Double-aliases not allowed, please fix '.
|
||||||
'ConfigSchema bug with' . "$namespace.$key", E_USER_ERROR);
|
'ConfigSchema bug with' . "$namespace.$key", E_USER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->set($new_ns = $this->def->info[$namespace][$key]->namespace,
|
$this->set($new_ns = $def->namespace,
|
||||||
$new_dir = $this->def->info[$namespace][$key]->name,
|
$new_dir = $def->name,
|
||||||
$value, true);
|
$value, true);
|
||||||
trigger_error("$namespace.$key is an alias, preferred directive name is $new_ns.$new_dir", E_USER_NOTICE);
|
trigger_error("$namespace.$key is an alias, preferred directive name is $new_ns.$new_dir", E_USER_NOTICE);
|
||||||
return;
|
return;
|
||||||
@ -211,16 +213,13 @@ class HTMLPurifier_Config
|
|||||||
|
|
||||||
// Raw type might be negative when using the fully optimized form
|
// Raw type might be negative when using the fully optimized form
|
||||||
// of stdclass, which indicates allow_null == true
|
// of stdclass, which indicates allow_null == true
|
||||||
$rtype =
|
$rtype = is_int($def) ? $def : $def->type;
|
||||||
is_int($this->def->info[$namespace][$key]) ?
|
|
||||||
$this->def->info[$namespace][$key] :
|
|
||||||
$this->def->info[$namespace][$key]->type;
|
|
||||||
if ($rtype < 0) {
|
if ($rtype < 0) {
|
||||||
$type = -$rtype;
|
$type = -$rtype;
|
||||||
$allow_null = true;
|
$allow_null = true;
|
||||||
} else {
|
} else {
|
||||||
$type = $rtype;
|
$type = $rtype;
|
||||||
$allow_null = isset($this->def->info[$namespace][$key]->allow_null);
|
$allow_null = isset($def->allow_null);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -229,20 +228,18 @@ class HTMLPurifier_Config
|
|||||||
trigger_error('Value for ' . "$namespace.$key" . ' is of invalid type, should be ' . HTMLPurifier_VarParser::getTypeName($type), E_USER_WARNING);
|
trigger_error('Value for ' . "$namespace.$key" . ' is of invalid type, should be ' . HTMLPurifier_VarParser::getTypeName($type), E_USER_WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_string($value)) {
|
if (is_string($value) && is_object($def)) {
|
||||||
// resolve value alias if defined
|
// resolve value alias if defined
|
||||||
if (isset($this->def->info[$namespace][$key]->aliases[$value])) {
|
if (isset($def->aliases[$value])) {
|
||||||
$value = $this->def->info[$namespace][$key]->aliases[$value];
|
$value = $def->aliases[$value];
|
||||||
}
|
}
|
||||||
if (isset($this->def->info[$namespace][$key])) {
|
|
||||||
// check to see if the value is allowed
|
// check to see if the value is allowed
|
||||||
if (isset($this->def->info[$namespace][$key]->allowed) && !isset($this->def->info[$namespace][$key]->allowed[$value])) {
|
if (isset($def->allowed) && !isset($def->allowed[$value])) {
|
||||||
trigger_error('Value not supported, valid values are: ' .
|
trigger_error('Value not supported, valid values are: ' .
|
||||||
$this->_listify($this->def->info[$namespace][$key]->allowed), E_USER_WARNING);
|
$this->_listify($def->allowed), E_USER_WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->conf[$namespace][$key] = $value;
|
$this->conf[$namespace][$key] = $value;
|
||||||
|
|
||||||
// reset definitions if the directives they depend on changed
|
// reset definitions if the directives they depend on changed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user