srcAttr->addValues($isOnCurrentHostAttr); $this->hrefAttr->addValues($isOnCurrentHostAttr, $isTypo3Uri); // @todo `style` used in Introduction Package, inline CSS should be removed $this->globalAttrs[] = new Behavior\Attr('style'); } public function build(): Sanitizer { $behavior = $this->createBehavior(); $visitor = GeneralUtility::makeInstance(CommonVisitor::class, $behavior); return GeneralUtility::makeInstance(Sanitizer::class, $behavior, $visitor); } protected function createBehavior(): Behavior { if (!isset($this->behavior)) { $this->behavior = parent::createBehavior() ->withName('default') ->withNodes(new Behavior\NodeHandler( new Behavior\Tag('svg'), new Behavior\Handler\ClosureHandler( static function (NodeInterface $node, ?\DOMNode $domNode, Context $context): ?\DOMNode { if ($domNode === null) { return null; } $newNode = GeneralUtility::makeInstance(SvgSanitizer::class) ->sanitizeNode($domNode); // purge empty svg nodes if ($newNode->childNodes->length === 0) { return null; } $fragment = $domNode->ownerDocument->createDocumentFragment(); $fragment->append($newNode); return $fragment; } ) )); } return $this->behavior; } }