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

Sanitizes a CSS stylesheet or rule list. More...

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

Public Member Functions

 __construct (array $ruleSanitizers=[])
 
 getRuleSanitizers ()
 Access the list of rule sanitizers.
 
 setRuleSanitizers (array $ruleSanitizers)
 Set the list of rule sanitizers.
 
- Public Member Functions inherited from Wikimedia\CSS\Sanitizer\Sanitizer
 getSanitizationErrors ()
 Return all sanitization errors seen so far.
 
 stashSanitizationErrors ()
 Temporarily clear sanitization errors.
 
 clearSanitizationErrors ()
 Clear sanitization errors.
 
 sanitize (CSSObject $object)
 Sanitize a CSS object.
 

Static Public Member Functions

static newDefault ()
 Create and return a default StylesheetSanitizer.
 

Protected Member Functions

 doSanitize (CSSObject $object)
 @inheritDoc
 
- Protected Member Functions inherited from Wikimedia\CSS\Sanitizer\Sanitizer
 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.
 

Protected Attributes

 $ruleSanitizers
 
- Protected Attributes inherited from Wikimedia\CSS\Sanitizer\Sanitizer
 $sanitizationErrors = []
 

Detailed Description

Sanitizes a CSS stylesheet or rule list.

See also
https://www.w3.org/TR/2019/CR-css-syntax-3-20190716/#css-stylesheets

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\CSS\Sanitizer\StylesheetSanitizer::__construct ( array $ruleSanitizers = [])
Parameters
RuleSanitizer[]$ruleSanitizersSanitizers to test rules. For each rule in the sheet, the first sanitizer that handles that rule gets to sanitize it.

Member Function Documentation

◆ doSanitize()

Wikimedia\CSS\Sanitizer\StylesheetSanitizer::doSanitize ( CSSObject $object)
protected

@inheritDoc

Reimplemented from Wikimedia\CSS\Sanitizer\Sanitizer.

◆ getRuleSanitizers()

Wikimedia\CSS\Sanitizer\StylesheetSanitizer::getRuleSanitizers ( )

Access the list of rule sanitizers.

Returns
RuleSanitizer[]

◆ newDefault()

static Wikimedia\CSS\Sanitizer\StylesheetSanitizer::newDefault ( )
static

Create and return a default StylesheetSanitizer.

Note
This method exists more to be an example of how to put everything together than to be used directly.
Returns
StylesheetSanitizer

◆ setRuleSanitizers()

Wikimedia\CSS\Sanitizer\StylesheetSanitizer::setRuleSanitizers ( array $ruleSanitizers)

Set the list of rule sanitizers.

Parameters
RuleSanitizer[]$ruleSanitizers

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