HumHub Documentation (unofficial)

HTMLPurifier
in package

Facade that coordinates HTML Purifier's subsystems in order to purify HTML.

Tags
note

There are several points in which configuration can be specified for HTML Purifier. The precedence of these (from lowest to highest) is as follows: -# Instance: new HTMLPurifier($config) -# Invocation: purify($html, $config) These configurations are entirely independent of each other and are not merged (this behavior may change in the future).

todo

We need an easier way to inject strategies using the configuration object.

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
type

HTMLPurifier_Config

$context

Resultant context of last run purification.

public mixed $context

Is an array of contexts if the last called method was purifyArray().

Tags
type

HTMLPurifier_Context

$version

Version of HTML Purifier.

public mixed $version = '4.17.0'
Tags
type

string

$generator

protected mixed $generator
Tags
type

HTMLPurifier_Generator

$strategy

protected mixed $strategy
Tags
type

HTMLPurifier_Strategy_Core

$filters

Array of extra filter objects to run on HTML, for backwards compatibility.

private mixed $filters = array()
Tags
type

HTMLPurifier_Filter[]

$instance

Single instance of HTML Purifier.

private static mixed $instance
Tags
type

HTMLPurifier

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.

purify()

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


        
On this page

Search results