Sanitizer
class Sanitizer (View source)
Properties
protected Filesystem | $filesystem | The Filesystem instance to be used for file operations. |
|
protected Sanitizer | $enshrinedSvgSanitizer | 3rd party SVG Sanitizer for additional checkups. |
Methods
Initialize the instance.
Check if a file is a valid XML file.
Check if a string contains valid XML data.
Check if an SVG file contain nodes to be sanitized.
Check if a string containing an SVG document contains nodes to be sanitized.
Sanitize a file containing an SVG document.
Sanitize a string containing an SVG document.
Sanitize a DOMDocument instance.
Get the flags to be used when loading the XML.
Reads a file.
Create a DOMDocument instance from a file name.
Create a DOMDocument instance from a string.
Analyze an element (and all its children), removing selected elements/attributes.
Details
__construct(Filesystem $filesystem)
Initialize the instance.
bool
fileContainsValidXml(string $filename)
Check if a file is a valid XML file.
bool
dataContainsValidXml(string $data)
Check if a string contains valid XML data.
array
checkFile(string $inputFilename, SanitizerOptions $options = null)
Check if an SVG file contain nodes to be sanitized.
array
checkData(string $data, SanitizerOptions $options = null)
Check if a string containing an SVG document contains nodes to be sanitized.
sanitizeFile(string $inputFilename, SanitizerOptions $options = null, string $outputFilename = '', array $removedNodes = [])
Sanitize a file containing an SVG document.
string
sanitizeData(string $data, SanitizerOptions $options = null, array $removedNodes = [])
Sanitize a string containing an SVG document.
protected
sanitizeXml(DOMDocument $xml, array $removedNodes, SanitizerOptions $options = null)
Sanitize a DOMDocument instance.
protected int
getLoadFlags()
Get the flags to be used when loading the XML.
protected string
fileToData(string $filename)
Reads a file.
protected DOMDocument
fileToXml(string $filename)
Create a DOMDocument instance from a file name.
protected DOMDocument
dataToXml(string $data)
Create a DOMDocument instance from a string.
protected
processNode(DOMElement $element, SanitizerOptions $options, array $removedNodes)
Analyze an element (and all its children), removing selected elements/attributes.
protected string
xmlToData(DOMDocument $xml)
Render a DOMDocument instance as a string.