SproutCMS

This is the code documentation for the SproutCMS project

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.

Extending this class

<?php
/**
* New class description goes here
* 
* @author Your Name, 2026-09-15
**/
class NewClassName extends RichTextSanitiser {
    
    /**
    * Gets a sanitised copy of the HTML
    **/
    public function sanitise () {
        // Method code goes here
    }
    
    /**
    * Checks whether any errors occurred during sanitising
    **/
    public function hasErrors () {
        // Method code goes here
    }
    
    /**
    * Get the list of errors produced during @see RichTextSanitiser::sanitise
    **/
    public function getErrors () {
        // Method code goes here
    }
    
    /**
    * Set whether to only allow local resources to be referenced by automatically fetching attributes
    * e.g. the src attribute on an &lt;img&gt; tag. Does not apply to the href attribute as that won't be
    * automatically fetched by a browser.
    **/
    public function setLocalResources (bool $local) {
        // Method code goes here
    }
    
    /**
    * Recursively sanitises a node and its children, echoing any output in order of appearance
    **/
    private function sanitiseNode (DOMNode $node) {
        // Method code goes here
    }
    
    /**
    * Encodes the value of an attribute using the correct encoding based on type
    **/
    private function encodeAttributeValue (int $type, string $value) {
        // Method code goes here
    }
    
    /**
    * Construct the sanitiser given a string of HTML
    **/
    public function __construct (string $richtextData, array $permitted_tags) {
        // Method code goes here
    }
    
}
?>