SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class RichTextSanitiser

Helper that strictly validates and sanitises user submitted HTML
Intended for use with front-end instances of TinyMCE to ensure XSS is impossible.

Variables

NameVisibilityDescription
$default_permitted_tags (static)
The default set of tags (and attributes) that are permitted
$dom_doc 
$errors 
$local_resources 
$permitted_tags 

Functions

NameVisibilityDescription
__constructpublicConstruct the sanitiser given a string of HTML
encodeAttributeValueprivateEncodes the value of an attribute using the correct encoding based on type
getErrorspublicGet the list of errors produced during @see RichTextSanitiser::sanitise
hasErrorspublicChecks whether any errors occurred during sanitising
sanitisepublicGets a sanitised copy of the HTML
sanitiseNodeprivateRecursively sanitises a node and its children, echoing any output in order of appearance
setLocalResourcespublicSet whether to only allow local resources to be referenced by automatically fetching attributes

public __construct

void $RichTextSanitiser->__construct ( string $richtextData [, array $permitted_tags ] );

Construct the sanitiser given a string of HTML

private encodeAttributeValue

string|bool $RichTextSanitiser->encodeAttributeValue ( int $type , string $value );

Encodes the value of an attribute using the correct encoding based on type

public getErrors

array $RichTextSanitiser->getErrors ( );

Get the list of errors produced during @see RichTextSanitiser::sanitise

public hasErrors

bool $RichTextSanitiser->hasErrors ( );

Checks whether any errors occurred during sanitising

public sanitise

string $RichTextSanitiser->sanitise ( );

Gets a sanitised copy of the HTML

private sanitiseNode

void $RichTextSanitiser->sanitiseNode ( DOMNode $node );

Recursively sanitises a node and its children, echoing any output in order of appearance

public setLocalResources

void $RichTextSanitiser->setLocalResources ( bool $local );

Set whether to only allow local resources to be referenced by automatically fetching attributes
e.g. the src attribute on an <img> tag. Does not apply to the href attribute as that won't be
automatically fetched by a browser.