This is an old revision of the document!
Table of Contents
HTMLPurifier
Layer: Core · Source: lib/core/HTMLPurifier.php:54 (lines 54–296)
class HTMLPurifier
Facade that coordinates HTML Purifier's subsystems in order to purify HTML.
Docblock Metadata
| Tag | Value |
|---|---|
@todo | We need an easier way to inject strategies using the configuration object. |
TODO
- We need an easier way to inject strategies using the configuration object.
Inheritance
No parent, interface or trait. This is a root type.
Constants (1)
| Visibility | Name | Value | Line |
|---|---|---|---|
- | VERSION | '4.15.0'; | 65 |
Properties (2)
| Visibility | Type | Name | Default | Line |
|---|---|---|---|---|
public | (untyped) | $version | '4.15.0'; | 60 |
private | (untyped) | $filters | array(); | 78 |
Methods (6)
| Visibility | Method | Summary | Line |
|---|---|---|---|
| public | __construct() | Initializes the purifier. | 113 |
| public | addFilter() | Adds a filter to process the output. First come first serve | 124 |
| public | purify() | Filters an HTML snippet/document to be XSS-free and standards-compliant. | 145 |
| public | purifyArray() | Filters an array of HTML snippets | 239 |
| public static | instance() | Singleton for enforcing just one HTML Purifier in your system | 267 |
| public static | getInstance() | Singleton for enforcing just one HTML Purifier in your system | 292 |
__construct()
public function __construct($config = null)
lines 113–117 (5)
Initializes the purifier.
| Parameter | Type | Default | Description |
|---|---|---|---|
$config | (untyped) | 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 ba… |
addFilter()
public function addFilter($filter)
lines 124–132 (9)
Adds a filter to process the output. First come first serve
| Parameter | Type | Default | Description |
|---|---|---|---|
$filter | (untyped) | required | HTMLPurifier_Filter object |
Returns: (none declared)
purify()
public function purify($html, $config = null)
lines 145–228 (84)
Filters an HTML snippet/document to be XSS-free and standards-compliant.
| Parameter | Type | Default | Description |
|---|---|---|---|
$html | (untyped) | required | String of HTML to purify |
$config | (untyped) | 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 tha… |
Returns: (none declared) — string Purified HTML
purifyArray()
public function purifyArray($array_of_html, $config = null)
lines 239–254 (16)
Filters an array of HTML snippets
| Parameter | Type | Default | Description |
|---|---|---|---|
$array_of_html | (untyped) | required | Array of html snippets |
$config | (untyped) | null | Optional config object for this operation. See HTMLPurifier::purify() for more details. |
Returns: (none declared) — string[] Array of purified HTML
instance()
public static function instance($prototype = null)
lines 267–279 (13)
Singleton for enforcing just one HTML Purifier in your system
| Parameter | Type | Default | Description |
|---|---|---|---|
$prototype | (untyped) | null | Optional prototype HTMLPurifier instance to overload singleton with, or HTMLPurifier_Config instance to configure the generated version with. |
Returns: (none declared) — HTMLPurifier
getInstance()
public static function getInstance($prototype = null)
lines 292–295 (4)
Singleton for enforcing just one HTML Purifier in your system
| Parameter | Type | Default | Description |
|---|---|---|---|
$prototype | (untyped) | null | Optional prototype HTMLPurifier instance to overload singleton with, or HTMLPurifier_Config instance to configure the generated version with. |
Returns: (none declared) — HTMLPurifier
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
