class Sanitizer (View source)

Properties

protected Filesystem $filesystem

The Filesystem instance to be used for file operations.

Methods

__construct(Filesystem $filesystem)

Initialize the instance.

sanitizeFile(string $inputFilename, SanitizerOptions $options = null, string $outputFilename = '')

Sanitize a file containing an SVG document.

string
sanitizeData(string $data, SanitizerOptions $options = null)

Sanitize a string containing an SVG document.

int
getLoadFlags()

Get the flags to be used when loading the XML.

dataToXml(string $data)

Create a DOMDocument instance from a string.

processNode(DOMElement $element, SanitizerOptions $options)

Analyze an element (and all its children), removing selected elements/attributes.

string
xmlToData(DOMDocument $xml)

Render a DOMDocument instance as a string.

Details

__construct(Filesystem $filesystem)

Initialize the instance.

Parameters

Filesystem $filesystem

the Filesystem instance to be used for file operations

sanitizeFile(string $inputFilename, SanitizerOptions $options = null, string $outputFilename = '')

Sanitize a file containing an SVG document.

Parameters

string $inputFilename

the input filename

SanitizerOptions $options

the sanitizer options (if NULL, we'll use the default ones)

string $outputFilename

the output filename (if empty, we'll overwrite $inputFilename)

Exceptions

SanitizerException

string sanitizeData(string $data, SanitizerOptions $options = null)

Sanitize a string containing an SVG document.

Parameters

string $data

the input filename

SanitizerOptions $options

the sanitizer options (if NULL, we'll use the default ones)

Return Value

string

Exceptions

SanitizerException

protected int getLoadFlags()

Get the flags to be used when loading the XML.

Return Value

int

protected DOMDocument dataToXml(string $data)

Create a DOMDocument instance from a string.

Parameters

string $data

Return Value

DOMDocument

Exceptions

SanitizerException

protected processNode(DOMElement $element, SanitizerOptions $options)

Analyze an element (and all its children), removing selected elements/attributes.

Parameters

DOMElement $element
SanitizerOptions $options

protected string xmlToData(DOMDocument $xml)

Render a DOMDocument instance as a string.

Parameters

DOMDocument $xml

Return Value

string

Exceptions

SanitizerException