HTMLPurifier_Config
Configuration object that triggers customizable behavior.
- Full name:
\HTMLPurifier_Config
Properties
version
HTML Purifier's version
autoFinalize
Whether or not to automatically finalize the object if a read operation is done.
serials
Namespace indexed array of serials for specific namespaces.
See Also:
- \getSerial() - for more info.
serial
Serial for entire configuration object.
parser
Parser for variables.
def
Reference HTMLPurifier_ConfigSchema for value checking.
definitions
Indexed array of definitions.
finalized
Whether or not config is finalized.
plist
Property list containing configuration directives.
aliasMode
Whether or not a set is taking place due to an alias lookup.
chatty
Set to false if you do not want line and file numbers in errors.
(useful when unit testing). This will also compress some errors and exceptions.
lock
Current lock; only gets to this namespace are allowed.
Methods
__construct
Constructor
public __construct(\HTMLPurifier_ConfigSchema $definition, \HTMLPurifier_PropertyList $parent = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
\HTMLPurifier_ConfigSchema | ConfigSchema that defines what directives are allowed. |
$parent |
\HTMLPurifier_PropertyList |
create
Convenience constructor that creates a config object based on a mixed var
public static create(mixed $config, \HTMLPurifier_ConfigSchema $schema = null): \HTMLPurifier_Config
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$config |
mixed | Variable that defines the state of the config object. Can be: a HTMLPurifier_Config() object, an array of directives based on loadArray(), or a string filename of an ini file. |
$schema |
\HTMLPurifier_ConfigSchema | Schema object |
Return Value:
Configured object
inherit
Creates a new config object that inherits from a previous one.
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$config |
\HTMLPurifier_Config | Configuration object to inherit from. |
Return Value:
object with $config as its parent.
createDefault
Convenience constructor that creates a default configuration object.
- This method is static.
Return Value:
default object.
get
Retrieves a value from the configuration.
Parameters:
Parameter | Type | Description |
---|---|---|
$key |
string | String key |
$a |
mixed |
getBatch
Retrieves an array of directives to values from a given namespace
Parameters:
Parameter | Type | Description |
---|---|---|
$namespace |
string | String namespace |
getBatchSerial
Returns a SHA-1 signature of a segment of the configuration object that uniquely identifies that particular configuration
Parameters:
Parameter | Type | Description |
---|---|---|
$namespace |
string | Namespace to get serial for |
getSerial
Returns a SHA-1 signature for the entire configuration object that uniquely identifies that particular configuration
getAll
Retrieves all directives, organized by namespace
set
Sets a value to configuration.
Parameters:
Parameter | Type | Description |
---|---|---|
$key |
string | key |
$value |
mixed | value |
$a |
mixed |
_listify
Convenience function for error reporting
Parameters:
Parameter | Type | Description |
---|---|---|
$lookup |
array |
getHTMLDefinition
Retrieves object reference to the HTML definition.
public getHTMLDefinition(bool $raw = false, bool $optimized = false): \HTMLPurifier_HTMLDefinition|null
Parameters:
Parameter | Type | Description |
---|---|---|
$raw |
bool | Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work. |
$optimized |
bool | If true, this method may return null, to indicate that a cached version of the modified definition object is available and no further edits are necessary. Consider using maybeGetRawHTMLDefinition, which is more explicitly named, instead. |
getCSSDefinition
Retrieves object reference to the CSS definition
public getCSSDefinition(bool $raw = false, bool $optimized = false): \HTMLPurifier_CSSDefinition|null
Parameters:
Parameter | Type | Description |
---|---|---|
$raw |
bool | Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work. |
$optimized |
bool | If true, this method may return null, to indicate that a cached version of the modified definition object is available and no further edits are necessary. Consider using maybeGetRawCSSDefinition, which is more explicitly named, instead. |
getURIDefinition
Retrieves object reference to the URI definition
public getURIDefinition(bool $raw = false, bool $optimized = false): \HTMLPurifier_URIDefinition|null
Parameters:
Parameter | Type | Description |
---|---|---|
$raw |
bool | Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work. |
$optimized |
bool | If true, this method may return null, to indicate that a cached version of the modified definition object is available and no further edits are necessary. Consider using maybeGetRawURIDefinition, which is more explicitly named, instead. |
getDefinition
Retrieves a definition
public getDefinition(string $type, bool $raw = false, bool $optimized = false): \HTMLPurifier_Definition|null
Parameters:
Parameter | Type | Description |
---|---|---|
$type |
string | Type of definition: HTML, CSS, etc |
$raw |
bool | Whether or not definition should be returned raw |
$optimized |
bool | Only has an effect when $raw is true. Whether or not to return null if the result is already present in the cache. This is off by default for backwards compatibility reasons, but you need to do things this way in order to ensure that caching is done properly. Check out enduser-customize.html for more details. We probably won't ever change this default, as much as the maybe semantics is the "right thing to do." |
Throws:
initDefinition
Initialise definition
private initDefinition(string $type): \HTMLPurifier_CSSDefinition|\HTMLPurifier_HTMLDefinition|\HTMLPurifier_URIDefinition
Parameters:
Parameter | Type | Description |
---|---|---|
$type |
string | What type of definition to create |
Throws:
maybeGetRawDefinition
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
mixed |
maybeGetRawHTMLDefinition
maybeGetRawCSSDefinition
maybeGetRawURIDefinition
loadArray
Loads configuration values from an array with the following structure: Namespace.Directive => Value
Parameters:
Parameter | Type | Description |
---|---|---|
$config_array |
array | Configuration associative array |
getAllowedDirectivesForForm
Returns a list of array(namespace, directive) for all directives that are allowed in a web-form context as per an allowed namespaces/directives list.
public static getAllowedDirectivesForForm(array $allowed, \HTMLPurifier_ConfigSchema $schema = null): array
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$allowed |
array | List of allowed namespaces/directives |
$schema |
\HTMLPurifier_ConfigSchema | Schema to use, if not global copy |
loadArrayFromForm
Loads configuration values from $_GET/$_POST that were posted via ConfigForm
public static loadArrayFromForm(array $array, string|bool $index = false, array|bool $allowed = true, bool $mq_fix = true, \HTMLPurifier_ConfigSchema $schema = null): mixed
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | $_GET or $_POST array to import |
$index |
string|bool | Index/name that the config variables are in |
$allowed |
array|bool | List of allowed namespaces/directives |
$mq_fix |
bool | Boolean whether or not to enable magic quotes fix |
$schema |
\HTMLPurifier_ConfigSchema | Schema to use, if not global copy |
mergeArrayFromForm
Merges in configuration values from $_GET/$_POST to object. NOT STATIC.
public mergeArrayFromForm(array $array, string|bool $index = false, array|bool $allowed = true, bool $mq_fix = true): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | $_GET or $_POST array to import |
$index |
string|bool | Index/name that the config variables are in |
$allowed |
array|bool | List of allowed namespaces/directives |
$mq_fix |
bool | Boolean whether or not to enable magic quotes fix |
prepareArrayFromForm
Prepares an array from a form into something usable for the more strict parts of HTMLPurifier_Config
public static prepareArrayFromForm(array $array, string|bool $index = false, array|bool $allowed = true, bool $mq_fix = true, \HTMLPurifier_ConfigSchema $schema = null): array
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | $_GET or $_POST array to import |
$index |
string|bool | Index/name that the config variables are in |
$allowed |
array|bool | List of allowed namespaces/directives |
$mq_fix |
bool | Boolean whether or not to enable magic quotes fix |
$schema |
\HTMLPurifier_ConfigSchema | Schema to use, if not global copy |
loadIni
Loads configuration values from an ini file
Parameters:
Parameter | Type | Description |
---|---|---|
$filename |
string | Name of ini file |
isFinalized
Checks whether or not the configuration object is finalized.
Parameters:
Parameter | Type | Description |
---|---|---|
$error |
string|bool | String error message, or false for no error |
autoFinalize
Finalizes configuration only if auto finalize is on and not already finalized
finalize
Finalizes a configuration object, prohibiting further change
triggerError
Produces a nicely formatted error message by supplying the stack frame information OUTSIDE of HTMLPurifier_Config.
Parameters:
Parameter | Type | Description |
---|---|---|
$msg |
string | An error message |
$no |
int | An error number |
serialize
Returns a serialized form of the configuration object that can be reconstituted.
Automatically generated on 2025-03-18