HTMLPurifier
in package
Facade that coordinates HTML Purifier's subsystems in order to purify HTML.
Tags
Table of Contents
Constants
- VERSION = '4.17.0'
- Constant with version of HTML Purifier.
Properties
- $config : mixed
- Global configuration object.
- $context : mixed
- Resultant context of last run purification.
- $version : mixed
- Version of HTML Purifier.
- $generator : mixed
- $strategy : mixed
- $filters : mixed
- Array of extra filter objects to run on HTML, for backwards compatibility.
- $instance : mixed
- Single instance of HTML Purifier.
Methods
- __construct() : mixed
- Initializes the purifier.
- addFilter() : mixed
- Adds a filter to process the output. First come first serve
- getInstance() : HTMLPurifier
- Singleton for enforcing just one HTML Purifier in your system
- instance() : HTMLPurifier
- Singleton for enforcing just one HTML Purifier in your system
- purify() : string
- Filters an HTML snippet/document to be XSS-free and standards-compliant.
- purifyArray() : array<string|int, string>
- Filters an array of HTML snippets
Constants
VERSION
Constant with version of HTML Purifier.
public
mixed
VERSION
= '4.17.0'
Properties
$config
Global configuration object.
public
mixed
$config
Tags
$context
Resultant context of last run purification.
public
mixed
$context
Is an array of contexts if the last called method was purifyArray().
Tags
$version
Version of HTML Purifier.
public
mixed
$version
= '4.17.0'
Tags
$generator
protected
mixed
$generator
Tags
$strategy
protected
mixed
$strategy
Tags
$filters
Array of extra filter objects to run on HTML, for backwards compatibility.
private
mixed
$filters
= array()
Tags
$instance
Single instance of HTML Purifier.
private
static mixed
$instance
Tags
Methods
__construct()
Initializes the purifier.
public
__construct([HTMLPurifier_Config|mixed $config = null ]) : mixed
Parameters
- $config : HTMLPurifier_Config|mixed = null
-
Optional HTMLPurifier_Config object for all instances of the purifier, if omitted, a default configuration is supplied (which can be overridden on a per-use basis). The parameter can also be any type that HTMLPurifier_Config::create() supports.
addFilter()
Adds a filter to process the output. First come first serve
public
addFilter(HTMLPurifier_Filter $filter) : mixed
Parameters
- $filter : HTMLPurifier_Filter
-
HTMLPurifier_Filter object
getInstance()
Singleton for enforcing just one HTML Purifier in your system
public
static getInstance([HTMLPurifier|HTMLPurifier_Config $prototype = null ]) : HTMLPurifier
Parameters
- $prototype : HTMLPurifier|HTMLPurifier_Config = null
-
Optional prototype HTMLPurifier instance to overload singleton with, or HTMLPurifier_Config instance to configure the generated version with.
Tags
Return values
HTMLPurifierinstance()
Singleton for enforcing just one HTML Purifier in your system
public
static instance([HTMLPurifier|HTMLPurifier_Config $prototype = null ]) : HTMLPurifier
Parameters
- $prototype : HTMLPurifier|HTMLPurifier_Config = null
-
Optional prototype HTMLPurifier instance to overload singleton with, or HTMLPurifier_Config instance to configure the generated version with.
Return values
HTMLPurifierpurify()
Filters an HTML snippet/document to be XSS-free and standards-compliant.
public
purify(string $html[, HTMLPurifier_Config $config = null ]) : string
Parameters
- $html : string
-
String of HTML to purify
- $config : HTMLPurifier_Config = null
-
Config object for this operation, if omitted, defaults to the config object specified during this object's construction. The parameter can also be any type that HTMLPurifier_Config::create() supports.
Return values
string —Purified HTML
purifyArray()
Filters an array of HTML snippets
public
purifyArray(array<string|int, string> $array_of_html[, HTMLPurifier_Config $config = null ]) : array<string|int, string>
Parameters
- $array_of_html : array<string|int, string>
-
Array of html snippets
- $config : HTMLPurifier_Config = null
-
Optional config object for this operation. See HTMLPurifier::purify() for more details.
Return values
array<string|int, string> —Array of purified HTML