108        $parent = $parent ? $parent : $definition->defaultPlist;
 
  110        $this->def = $definition; 
 
  169    public function get(
$key, $a = 
null)
 
  173                "Using deprecated API: use \$config->get('$key.$a') instead",
 
  178        if (!$this->finalized) {
 
  181        if (!isset($this->def->info[
$key])) {
 
  184                'Cannot retrieve value of undefined directive ' . htmlspecialchars(
$key),
 
  189        if (isset($this->def->info[
$key]->isAlias)) {
 
  190            $d = $this->def->info[
$key];
 
  192                'Cannot get value from aliased directive, use real name ' . 
$d->key,
 
  198            list($ns) = explode(
'.', 
$key);
 
  199            if ($ns !== $this->lock) {
 
  201                    'Cannot get value of namespace ' . $ns . 
' when lock for ' .
 
  203                    ' is active, this probably indicates a Definition setup method ' .
 
  204                    'is accessing directives that are not within its namespace',
 
  210        return $this->plist->get(
$key);
 
  222        if (!$this->finalized) {
 
  228                'Cannot retrieve undefined namespace ' .
 
  250            $batch = $this->
getBatch($namespace);
 
  251            unset($batch[
'DefinitionRev']);
 
  265        if (empty($this->serial)) {
 
  278        if (!$this->finalized) {
 
  282        foreach ($this->plist->squash() as 
$name => $value) {
 
  283            list($ns, 
$key) = explode(
'.', 
$name, 2);
 
  296    public function set(
$key, $value, $a = 
null)
 
  298        if (strpos(
$key, 
'.') === 
false) {
 
  302            $key = 
"$key.$directive";
 
  303            $this->
triggerError(
"Using deprecated API: use \$config->set('$key', ...) instead", E_USER_NOTICE);
 
  307        if ($this->
isFinalized(
'Cannot set directive after finalization')) {
 
  310        if (!isset($this->def->info[
$key])) {
 
  312                'Cannot set undefined directive ' . htmlspecialchars(
$key) . 
' to value',
 
  319        if (isset(
$def->isAlias)) {
 
  320            if ($this->aliasMode) {
 
  322                    'Double-aliases not allowed, please fix '.
 
  323                    'ConfigSchema bug with' . 
$key,
 
  328            $this->aliasMode = 
true;
 
  329            $this->
set(
$def->key, $value);
 
  330            $this->aliasMode = 
false;
 
  331            $this->
triggerError(
"$key is an alias, preferred directive name is {$def->key}", E_USER_NOTICE);
 
  343            $allow_null = isset(
$def->allow_null);
 
  347            $value = $this->parser->parse($value, 
$type, $allow_null);
 
  350                'Value for ' . 
$key . 
' is of invalid type, should be ' .
 
  356        if (is_string($value) && is_object(
$def)) {
 
  358            if (isset(
$def->aliases[$value])) {
 
  359                $value = 
$def->aliases[$value];
 
  362            if (isset(
$def->allowed) && !isset(
$def->allowed[$value])) {
 
  364                    'Value not supported, valid values are: ' .
 
  371        $this->plist->set(
$key, $value);
 
  393        foreach ($lookup as 
$name => $b) {
 
  396        return implode(
', ', 
$list);
 
  475        if ($optimized && !$raw) {
 
  478        if (!$this->finalized) {
 
  491            if (!empty($this->definitions[
$type])) {
 
  498                    if (
$def->optimized) {
 
  499                        $cache->add(
$def, $this);
 
  505            $def = $cache->get($this);
 
  518            $cache->add(
$def, $this);
 
  527                if (is_null($this->
get(
$type . 
'.DefinitionID'))) {
 
  530                        "Cannot retrieve raw version without specifying %$type.DefinitionID" 
  534            if (!empty($this->definitions[
$type])) {
 
  536                if (
$def->setup && !$optimized) {
 
  537                    $extra = $this->chatty ?
 
  538                        " (try moving this code block earlier in your initialization)" :
 
  541                        "Cannot retrieve raw definition after it has already been setup" .
 
  545                if (
$def->optimized === 
null) {
 
  546                    $extra = $this->chatty ? 
" (try flushing your cache)" : 
"";
 
  548                        "Optimization status of definition is unknown" . $extra
 
  551                if (
$def->optimized !== $optimized) {
 
  552                    $msg = $optimized ? 
"optimized" : 
"unoptimized";
 
  553                    $extra = $this->chatty ?
 
  554                        " (this backtrace is for the first inconsistent call, which was for a $msg raw definition)" 
  557                        "Inconsistent use of optimized and unoptimized raw definition retrievals" . $extra
 
  579                $def = $cache->get($this);
 
  589                if (!is_null($this->
get($type . 
'.DefinitionID'))) {
 
  592                            'Due to a documentation error in previous version of HTML Purifier, your ' .
 
  593                            'definitions are not being cached.  If this is OK, you can remove the ' .
 
  594                            '%$type.DefinitionRev and %$type.DefinitionID declaration.  Otherwise, ' .
 
  595                            'modify your code to use maybeGetRawDefinition, and test if the returned ' .
 
  596                            'value is null before making any edits (if it is null, that means that a ' .
 
  597                            'cached version is available, and no raw operations are necessary).  See ' .
 
  598                            '<a href="http://htmlpurifier.org/docs/enduser-customize.html#optimized">' .
 
  599                            'Customize</a> for more details',
 
  604                            "Useless DefinitionID declaration",
 
  612            $def->optimized = $optimized;
 
  629        if (
$type == 
'HTML') {
 
  631        } elseif (
$type == 
'CSS') {
 
  633        } elseif (
$type == 
'URI') {
 
  637                "Definition of $type type not supported" 
  681        if ($this->
isFinalized(
'Cannot load directives after finalization')) {
 
  684        foreach ($config_array as 
$key => $value) {
 
  686            if (strpos(
$key, 
'.') !== 
false) {
 
  687                $this->
set(
$key, $value);
 
  690                $namespace_values = $value;
 
  691                foreach ($namespace_values as $directive => $value2) {
 
  692                    $this->
set(
$namespace .
'.'. $directive, $value2);
 
  713        if ($allowed !== 
true) {
 
  714            if (is_string($allowed)) {
 
  715                $allowed = array($allowed);
 
  717            $allowed_ns = array();
 
  718            $allowed_directives = array();
 
  719            $blacklisted_directives = array();
 
  720            foreach ($allowed as $ns_or_directive) {
 
  721                if (strpos($ns_or_directive, 
'.') !== 
false) {
 
  723                    if ($ns_or_directive[0] == 
'-') {
 
  724                        $blacklisted_directives[substr($ns_or_directive, 1)] = 
true;
 
  726                        $allowed_directives[$ns_or_directive] = 
true;
 
  730                    $allowed_ns[$ns_or_directive] = 
true;
 
  736            list($ns, $directive) = explode(
'.', 
$key, 2);
 
  737            if ($allowed !== 
true) {
 
  738                if (isset($blacklisted_directives[
"$ns.$directive"])) {
 
  741                if (!isset($allowed_directives[
"$ns.$directive"]) && !isset($allowed_ns[$ns])) {
 
  745            if (isset(
$def->isAlias)) {
 
  748            if ($directive == 
'DefinitionID' || $directive == 
'DefinitionRev') {
 
  751            $ret[] = array($ns, $directive);
 
  804            $array = (isset($array[
$index]) && is_array($array[
$index])) ? $array[
$index] : array();
 
  806        $mq = $mq_fix && function_exists(
'get_magic_quotes_gpc') && get_magic_quotes_gpc();
 
  810        foreach ($allowed as 
$key) {
 
  811            list($ns, $directive) = 
$key;
 
  812            $skey = 
"$ns.$directive";
 
  813            if (!empty($array[
"Null_$skey"])) {
 
  814                $ret[$ns][$directive] = 
null;
 
  817            if (!isset($array[$skey])) {
 
  820            $value = $mq ? stripslashes($array[$skey]) : $array[$skey];
 
  821            $ret[$ns][$directive] = $value;
 
  833        if ($this->
isFinalized(
'Cannot load directives after finalization')) {
 
  836        $array = parse_ini_file(
$filename, 
true);
 
  849        if ($this->finalized && 
$error) {
 
  864            $this->plist->squash(
true);
 
  873        $this->finalized = 
true;
 
  874        $this->parser = 
null;
 
  889            $trace = debug_backtrace();
 
  891            for (
$i = 0, $c = count($trace); 
$i < $c - 1; 
$i++) {
 
  893                if ($trace[
$i + 1][
'class'] === 
'HTMLPurifier_Config') {
 
  897                $extra = 
" invoked on line {$frame['line']} in file {$frame['file']}";
 
  901        trigger_error($msg . $extra, $no);
 
An exception for terminatinating execution or to throw for unit testing.
Defines allowed CSS attributes and what their values are.
static instance($prototype=null)
Retrieves an instance of the application-wide configuration definition.
Configuration object that triggers customizable behavior.
static create($config, $schema=null)
Convenience constructor that creates a config object based on a mixed var.
static loadArrayFromForm($array, $index=false, $allowed=true, $mq_fix=true, $schema=null)
Loads configuration values from $_GET/$_POST that were posted via ConfigForm.
$plist
Property list containing configuration directives.
initDefinition($type)
Initialise definition.
static createDefault()
Convenience constructor that creates a default configuration object.
finalize()
Finalizes a configuration object, prohibiting further change.
maybeGetRawCSSDefinition()
$aliasMode
Whether or not a set is taking place due to an alias lookup.
getURIDefinition($raw=false, $optimized=false)
Retrieves object reference to the URI definition.
getBatchSerial($namespace)
Returns a SHA-1 signature of a segment of the configuration object that uniquely identifies that part...
static getAllowedDirectivesForForm($allowed, $schema=null)
Returns a list of array(namespace, directive) for all directives that are allowed in a web-form conte...
$parser
Parser for variables.
getBatch($namespace)
Retrieves an array of directives to values from a given namespace.
$lock
Current lock; only gets to this namespace are allowed.
_listify($lookup)
Convenience function for error reporting.
maybeGetRawURIDefinition()
$serial
Serial for entire configuration object.
loadArray($config_array)
Loads configuration values from an array with the following structure: Namespace.Directive => Value.
$finalized
Whether or not config is finalized.
$definitions
Indexed array of definitions.
getCSSDefinition($raw=false, $optimized=false)
Retrieves object reference to the CSS definition.
getHTMLDefinition($raw=false, $optimized=false)
Retrieves object reference to the HTML definition.
mergeArrayFromForm($array, $index=false, $allowed=true, $mq_fix=true)
Merges in configuration values from $_GET/$_POST to object.
autoFinalize()
Finalizes configuration only if auto finalize is on and not already finalized.
$version
HTML Purifier's version @type string.
$autoFinalize
Whether or not to automatically finalize the object if a read operation is done.
maybeGetRawDefinition($name)
static inherit(HTMLPurifier_Config $config)
Creates a new config object that inherits from a previous one.
__construct($definition, $parent=null)
Constructor.
$def
Reference HTMLPurifier_ConfigSchema for value checking.
isFinalized($error=false)
Checks whether or not the configuration object is finalized.
serialize()
Returns a serialized form of the configuration object that can be reconstituted.
triggerError($msg, $no)
Produces a nicely formatted error message by supplying the stack frame information OUTSIDE of HTMLPur...
$chatty
Set to false if you do not want line and file numbers in errors.
maybeGetRawHTMLDefinition()
loadIni($filename)
Loads configuration values from an ini file.
static prepareArrayFromForm($array, $index=false, $allowed=true, $mq_fix=true, $schema=null)
Prepares an array from a form into something usable for the more strict parts of HTMLPurifier_Config.
getAll()
Retrieves all directives, organized by namespace.
getDefinition($type, $raw=false, $optimized=false)
Retrieves a definition.
getSerial()
Returns a SHA-1 signature for the entire configuration object that uniquely identifies that particula...
$serials
Namespace indexed array of serials for specific namespaces.
static instance($prototype=null)
Retrieves an instance of global definition cache factory.
Global exception class for HTML Purifier; any exceptions we throw are from here.
Definition of the purified HTML that describes allowed children, attributes, and many other things.
Generic property list implementation.
Exception type for HTMLPurifier_VarParser.
Performs safe variable parsing based on types which can be used by users.
static getTypeName($type)
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
if($err=$client->getError()) $namespace
if(isset($_REQUEST['delete'])) $list