Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
Sanitize Class Reference

Used for data cleanup and post-processing. More...

Inheritance diagram for Sanitize:
RegistryAware

Public Member Functions

 add_attributes ($attribs=['audio'=>['preload'=> 'none'], 'iframe'=>['sandbox'=> 'allow-scripts allow-same-origin'], 'video'=>['preload'=> 'none']])
 
 do_strip_htmltags ($match)
 
 encode_instead_of_strip ($encode=false)
 
 https_url ($url)
 Force HTTPS for selected Web sites.
 
 pass_cache_data ($enable_cache=true, $cache_location='./cache', $cache_name_function='md5', $cache_class='SimplePie\Cache', DataCache $cache=null)
 
 pass_file_data ($file_class='SimplePie\File', $timeout=10, $useragent='', $force_fsockopen=false)
 
 remove_div ($enable=true)
 
 rename_attributes ($attribs=[])
 
 replace_urls ($document, $tag, $attributes)
 
 sanitize ($data, $type, $base='')
 
 set_https_domains ($domains)
 Set the list of domains for which to force HTTPS.
 
 set_image_handler ($page=false)
 
 set_output_encoding ($encoding='UTF-8')
 
 set_registry (Registry $registry)
 Set the Registry into the class.
 
 set_registry (\SimplePie\Registry $registry)
 
 set_url_replacements ($element_attribute=null)
 Set element/attribute key/value pairs of HTML attributes containing URLs that need to be resolved relative to the feed.
 
 strip_attributes ($attribs=['bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'])
 
 strip_comments ($strip=false)
 
 strip_htmltags ($tags=['base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'])
 

Public Attributes

 $add_attributes = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']]
 
 $base
 
 $cache_location = './cache'
 
 $cache_name_function = 'md5'
 
 $enable_cache = true
 
 $encode_instead_of_strip = false
 
 $force_fsockopen = false
 
 $https_domains = []
 List of domains for which to force HTTPS.
 
 $image_handler = ''
 
 $output_encoding = 'UTF-8'
 
 $registry
 
 $remove_div = true
 
 $rename_attributes = []
 
 $replace_url_attributes = null
 
 $strip_attributes = ['bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc']
 
 $strip_comments = false
 
 $strip_htmltags = ['base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style']
 
 $timeout = 10
 
 $useragent = ''
 

Protected Member Functions

 add_attr ($tag, $valuePairs, $document)
 
 is_https_domain ($domain)
 Check if the domain is in the list of forced HTTPS.
 
 preprocess ($html, $type)
 
 rename_attr ($attrib, $xpath)
 
 strip_attr ($attrib, $xpath)
 
 strip_tag ($tag, $document, $xpath, $type)
 

Detailed Description

Used for data cleanup and post-processing.

This class can be overloaded with {

See also
SimplePie\SimplePie\set_sanitize_class()}
Todo
Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags

Member Function Documentation

◆ set_https_domains()

Sanitize::set_https_domains ( $domains)

Set the list of domains for which to force HTTPS.

See also
SimplePie\Misc\https_url() Example array('biz', 'example.com', 'example.org', 'www.example.net');

◆ set_registry()

RegistryAware::set_registry ( Registry $registry)
inherited

Set the Registry into the class.

Parameters
Registry$registry
Return values
void

◆ set_url_replacements()

Sanitize::set_url_replacements ( $element_attribute = null)

Set element/attribute key/value pairs of HTML attributes containing URLs that need to be resolved relative to the feed.

Defaults to |a|@href, |area|@href, |audio|@src, |blockquote|

Member Data Documentation

◆ $https_domains

Sanitize::$https_domains = []

List of domains for which to force HTTPS.

See also
SimplePie\Sanitize\set_https_domains() Array is a tree split at DNS levels. Example: array('biz' => true, '.tecnick.tcpdf com.tecnick.tcpdf' => array('example' => true), 'net' => array('example' => array('www' => true)))

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