htmlpurifier  4.15.0
About: HTML Purifier is an HTML filtering solution. It tries to remove all malicious code (XSS) and to make sure the HTML is standards compliant.
  Fossies Dox: htmlpurifier-4.15.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
HTMLPurifier Class Reference

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

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 instance ($prototype=null)
 Singleton for enforcing just one HTML Purifier in your system.
 
static getInstance ($prototype=null)
 Singleton for enforcing just one HTML Purifier in your system.
 

Public Attributes

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

Protected Attributes

 $strategy
 @type HTMLPurifier_Strategy_Core
 
 $generator
 @type HTMLPurifier_Generator
 

Private Attributes

 $filters = array()
 Array of extra filter objects to run on HTML, for backwards compatibility.
 

Static Private Attributes

static $instance
 Single instance of HTML Purifier.
 

Detailed Description

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

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:
  1. Instance: new HTMLPurifier($config)
  2. 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.

Definition at line 54 of file HTMLPurifier.php.

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.

Definition at line 114 of file HTMLPurifier.php.

References $config, and HTMLPurifier_Config\create().

Member Function Documentation

◆ addFilter()

HTMLPurifier::addFilter (   $filter)

Adds a filter to process the output.

First come first serve

Parameters
HTMLPurifier_Filter$filterHTMLPurifier_Filter object

Definition at line 125 of file HTMLPurifier.php.

◆ 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.
Returns
HTMLPurifier
Note
Backwards compatibility, see instance()

Definition at line 291 of file HTMLPurifier.php.

References instance().

Referenced by phorum_htmlpurifier_before_editor(), phorum_htmlpurifier_common(), phorum_htmlpurifier_editor_after_subject(), phorum_htmlpurifier_format(), phorum_htmlpurifier_quote(), and HTMLPurifier_ConfigSchema_Builder_Xml\writeHTMLDiv().

◆ 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.
Returns
HTMLPurifier

Definition at line 266 of file HTMLPurifier.php.

References $instance.

Referenced by getInstance().

◆ 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.
Returns
string Purified HTML

Definition at line 146 of file HTMLPurifier.php.

References $config, $context, $filters, $html, $i, HTMLPurifier_IDAccumulator\build(), HTMLPurifier_Encoder\convertFromUTF8(), HTMLPurifier_Encoder\convertToUTF8(), HTMLPurifier_Lexer\create(), HTMLPurifier_Config\create(), and HTMLPurifier_LanguageFactory\instance().

Referenced by purifyArray().

◆ 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.
Returns
string[] Array of purified HTML

Definition at line 240 of file HTMLPurifier.php.

References $config, $context, purify(), and purifyArray().

Referenced by purifyArray().

Member Data Documentation

◆ $config

HTMLPurifier::$config

Global configuration object.

@type HTMLPurifier_Config

Definition at line 72 of file HTMLPurifier.php.

Referenced by __construct(), purify(), and purifyArray().

◆ $context

HTMLPurifier::$context

Resultant context of last run purification.

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

Definition at line 102 of file HTMLPurifier.php.

Referenced by purify(), and purifyArray().

◆ $filters

HTMLPurifier::$filters = array()
private

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

@type HTMLPurifier_Filter[]

Definition at line 79 of file HTMLPurifier.php.

Referenced by purify().

◆ $generator

HTMLPurifier::$generator
protected

@type HTMLPurifier_Generator

Definition at line 95 of file HTMLPurifier.php.

◆ $instance

HTMLPurifier::$instance
staticprivate

Single instance of HTML Purifier.

@type HTMLPurifier

Definition at line 85 of file HTMLPurifier.php.

Referenced by instance().

◆ $strategy

HTMLPurifier::$strategy
protected

@type HTMLPurifier_Strategy_Core

Definition at line 90 of file HTMLPurifier.php.

◆ $version

HTMLPurifier::$version = '4.15.0'

Version of HTML Purifier.

@type string

Definition at line 61 of file HTMLPurifier.php.

◆ VERSION

const HTMLPurifier::VERSION = '4.15.0'

Constant with version of HTML Purifier.

Definition at line 66 of file HTMLPurifier.php.


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