css-sanitizer
Classes to parse and sanitize CSS
Loading...
Searching...
No Matches
Wikimedia\CSS\Sanitizer\Sanitizer Class Reference

Base class for CSS sanitizers. More...

+ Inheritance diagram for Wikimedia\CSS\Sanitizer\Sanitizer:

Public Member Functions

 getSanitizationErrors ()
 Return all sanitization errors seen so far.
 
 stashSanitizationErrors ()
 Temporarily clear sanitization errors.
 
 clearSanitizationErrors ()
 Clear sanitization errors.
 
 sanitize (CSSObject $object)
 Sanitize a CSS object.
 

Protected Member Functions

 sanitizationError ( $tag, CSSObject $object, array $data=[])
 Record a sanitization error.
 
 sanitizeObj (Sanitizer $sanitizer, CSSObject $object)
 Run another sanitizer over a CSSObject.
 
 sanitizeList (Sanitizer $sanitizer, CSSObjectList $list)
 Run a sanitizer over all CSSObjects in a CSSObjectList.
 
 sanitizeRules (array $ruleSanitizers, RuleList $list)
 Run a set of RuleSanitizers over all rules in a RuleList.
 
 doSanitize (CSSObject $object)
 Sanitize a CSS object.
 

Protected Attributes

 $sanitizationErrors = []
 

Detailed Description

Base class for CSS sanitizers.

Member Function Documentation

◆ doSanitize()

◆ getSanitizationErrors()

Wikimedia\CSS\Sanitizer\Sanitizer::getSanitizationErrors ( )

Return all sanitization errors seen so far.

Returns
array Array of [ string $tag, int $line, int $pos, ... ]

◆ sanitizationError()

Wikimedia\CSS\Sanitizer\Sanitizer::sanitizationError ( $tag,
CSSObject $object,
array $data = [] )
protected

Record a sanitization error.

Parameters
string$tagError tag
CSSObject$objectReport the error starting at this object
array$dataExtra data about the error.

◆ sanitize()

Wikimedia\CSS\Sanitizer\Sanitizer::sanitize ( CSSObject $object)

Sanitize a CSS object.

Parameters
CSSObject$object
Returns
CSSObject|null Sanitized version of the object, or null if sanitization failed

◆ sanitizeList()

Wikimedia\CSS\Sanitizer\Sanitizer::sanitizeList ( Sanitizer $sanitizer,
CSSObjectList $list )
protected

Run a sanitizer over all CSSObjects in a CSSObjectList.

Parameters
Sanitizer$sanitizer
CSSObjectList$list
Returns
CSSObjectList

◆ sanitizeObj()

Wikimedia\CSS\Sanitizer\Sanitizer::sanitizeObj ( Sanitizer $sanitizer,
CSSObject $object )
protected

Run another sanitizer over a CSSObject.

Parameters
Sanitizer$sanitizer
CSSObject$object
Returns
CSSObject|null

◆ sanitizeRules()

Wikimedia\CSS\Sanitizer\Sanitizer::sanitizeRules ( array $ruleSanitizers,
RuleList $list )
protected

Run a set of RuleSanitizers over all rules in a RuleList.

Parameters
RuleSanitizer[]$ruleSanitizers
RuleList$list
Returns
RuleList

◆ stashSanitizationErrors()

Wikimedia\CSS\Sanitizer\Sanitizer::stashSanitizationErrors ( )

Temporarily clear sanitization errors.

Errors will be cleared, then restored when the returned ScopedCallback goes out of scope or is consumed.

Returns
ScopedCallback

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