Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
HTMLPurifier Class Reference

Public Member Functions

 __construct ($config=null)
 Initializes the purifier.
 
 addFilter ($filter)
 Adds a filter to process the output.
 
 purify ($html, $config=null)
 Filters an HTML snippet/document to be XSS-free and standards-compliant.
 
 purifyArray ($array_of_html, $config=null)
 Filters an array of HTML snippets.
 

Static Public Member Functions

static getInstance ($prototype=null)
 Singleton for enforcing just one HTML Purifier in your system.
 
static instance ($prototype=null)
 Singleton for enforcing just one HTML Purifier in your system.
 

Public Attributes

 $config
 Global configuration object.
 
 $context
 Resultant context of last run purification.
 
 $version = '4.15.0'
 Version of HTML Purifier.
 
const VERSION = '4.15.0'
 Constant with version of HTML Purifier.
 

Protected Attributes

 $generator
 @type HTMLPurifier_Generator
 
 $strategy
 @type HTMLPurifier_Strategy_Core
 

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier::__construct ( $config = null)

Initializes the purifier.

Parameters
HTMLPurifier_Config | mixed$configOptional 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.

Member Function Documentation

◆ addFilter()

HTMLPurifier::addFilter ( $filter)

Adds a filter to process the output.

First come first serve

Parameters
HTMLPurifier_Filter$filterHTMLPurifier_Filter object

◆ getInstance()

static HTMLPurifier::getInstance ( $prototype = null)
static

Singleton for enforcing just one HTML Purifier in your system.

Parameters
HTMLPurifier | HTMLPurifier_Config$prototypeOptional prototype HTMLPurifier instance to overload singleton with, or HTMLPurifier_Config instance to configure the generated version with.
Return values
HTMLPurifier
Note
Backwards compatibility, see instance()

◆ instance()

static HTMLPurifier::instance ( $prototype = null)
static

Singleton for enforcing just one HTML Purifier in your system.

Parameters
HTMLPurifier | HTMLPurifier_Config$prototypeOptional prototype HTMLPurifier instance to overload singleton with, or HTMLPurifier_Config instance to configure the generated version with.
Return values
HTMLPurifier

◆ purify()

HTMLPurifier::purify ( $html,
$config = null )

Filters an HTML snippet/document to be XSS-free and standards-compliant.

Parameters
string$htmlString of HTML to purify
HTMLPurifier_Config$configConfig 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
stringPurified HTML

◆ purifyArray()

HTMLPurifier::purifyArray ( $array_of_html,
$config = null )

Filters an array of HTML snippets.

Parameters
string[]$array_of_htmlArray of html snippets
HTMLPurifier_Config$configOptional config object for this operation. See HTMLPurifier\purify() for more details.
Return values
string[]Array of purified HTML

Member Data Documentation

◆ $config

HTMLPurifier::$config

Global configuration object.

@type HTMLPurifier_Config

◆ $context

HTMLPurifier::$context

Resultant context of last run purification.

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

◆ $version

HTMLPurifier::$version = '4.15.0'

Version of HTML Purifier.

@type string


The documentation for this class was generated from the following file: