HtmlEditorSanitiser
class HtmlEditorSanitiser (View source)
Sanitises an HTMLValue so it's contents are the elements and attributes that are whitelisted using the same configuration as TinyMCE
See www.tinymce.com/wiki.php/configuration:valid_elements for details on the spec of TinyMCE's whitelist configuration
Properties
protected | $elements | |||
protected | $elementPatterns | |||
protected | $globalAttributes |
Methods
Given a TinyMCE pattern (close to unix glob style), create a regex that does the match
Given a valid_elements string, parse out the actual element and attribute rules and add to the internal whitelist
Given an element tag, return the rule structure for that element
Given an attribute name, return the rule structure for that attribute
Given a DOMElement and an element rule, check if that element passes the rule
Given a DOMAttr and an attribute rule, check if that attribute passes the rule
Given an SS_HTMLValue instance, will remove and elements and attributes that are not explicitly included in the whitelist passed to __construct on instance creation
Details
__construct(HtmlEditorConfig $config)
Construct a sanitiser from a given HtmlEditorConfig
Note that we build data structures from the current state of HtmlEditorConfig - later changes to the passed instance won't cause this instance to update it's whitelist
protected string
patternToRegex($str)
Given a TinyMCE pattern (close to unix glob style), create a regex that does the match
protected
addValidElements(string $validElements)
Given a valid_elements string, parse out the actual element and attribute rules and add to the internal whitelist
Logic based heavily on javascript version from tiny_mce_src.js
protected stdClass
getRuleForElement(string $tag)
Given an element tag, return the rule structure for that element
protected stdClass
getRuleForAttribute(object $elementRule, string $name)
Given an attribute name, return the rule structure for that attribute
protected bool
elementMatchesRule(DOMElement $element, stdClass $rule = null)
Given a DOMElement and an element rule, check if that element passes the rule
protected bool
attributeMatchesRule(DOMAttr $attr, stdClass $rule = null)
Given a DOMAttr and an attribute rule, check if that attribute passes the rule
sanitise(SS_HTMLValue $html)
Given an SS_HTMLValue instance, will remove and elements and attributes that are not explicitly included in the whitelist passed to __construct on instance creation