mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-03 20:58:11 +02:00
[3.1.1] More ConfigSchema optimizations: degenerate form can accommodate type and allow_null
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1766 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -208,15 +208,23 @@ class HTMLPurifier_Config
|
||||
trigger_error("$namespace.$key is an alias, preferred directive name is $new_ns.$new_dir", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
|
||||
// Raw type might be negative when using the fully optimized form
|
||||
// of stdclass, which indicates allow_null == true
|
||||
$rtype =
|
||||
is_int($this->def->info[$namespace][$key]) ?
|
||||
$this->def->info[$namespace][$key] :
|
||||
$this->def->info[$namespace][$key]->type;
|
||||
if ($rtype < 0) {
|
||||
$type = -$rtype;
|
||||
$allow_null = true;
|
||||
} else {
|
||||
$type = $rtype;
|
||||
$allow_null = isset($this->def->info[$namespace][$key]->allow_null);
|
||||
}
|
||||
|
||||
try {
|
||||
$value = $this->parser->parse(
|
||||
$value,
|
||||
$type =
|
||||
is_int($this->def->info[$namespace][$key]) ?
|
||||
$this->def->info[$namespace][$key] :
|
||||
$this->def->info[$namespace][$key]->type,
|
||||
isset($this->def->info[$namespace][$key]->allow_null)
|
||||
);
|
||||
$value = $this->parser->parse($value, $type, $allow_null);
|
||||
} catch (HTMLPurifier_VarParserException $e) {
|
||||
trigger_error('Value for ' . "$namespace.$key" . ' is of invalid type, should be ' . HTMLPurifier_VarParser::getTypeName($type), E_USER_WARNING);
|
||||
return;
|
||||
|
Reference in New Issue
Block a user