ExtraExtension.php000064400000002463150031564100010235 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra; use HtmlSanitizer\Extension\ExtensionInterface; /** * @author Titouan Galopin * * @final */ class ExtraExtension implements ExtensionInterface { public function getName(): string { return 'extra'; } public function createNodeVisitors(array $config = []): array { return [ 'abbr' => new NodeVisitor\AbbrNodeVisitor($config['tags']['abbr'] ?? []), 'caption' => new NodeVisitor\CaptionNodeVisitor($config['tags']['caption'] ?? []), 'hr' => new NodeVisitor\HrNodeVisitor($config['tags']['hr'] ?? []), 'mark' => new NodeVisitor\MarkNodeVisitor($config['tags']['mark'] ?? []), 'rp' => new NodeVisitor\RpNodeVisitor($config['tags']['rp'] ?? []), 'rt' => new NodeVisitor\RtNodeVisitor($config['tags']['rt'] ?? []), 'ruby' => new NodeVisitor\RubyNodeVisitor($config['tags']['ruby'] ?? []), 'time' => new NodeVisitor\TimeNodeVisitor($config['tags']['time'] ?? []), ]; } } NodeVisitor/TimeNodeVisitor.php000064400000002122150031564100012576 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\NodeVisitor; use HtmlSanitizer\Extension\Extra\Node\TimeNode; use HtmlSanitizer\Model\Cursor; use HtmlSanitizer\Node\NodeInterface; use HtmlSanitizer\Visitor\AbstractNodeVisitor; use HtmlSanitizer\Visitor\HasChildrenNodeVisitorTrait; use HtmlSanitizer\Visitor\NamedNodeVisitorInterface; /** * @author Titouan Galopin * * @final */ class TimeNodeVisitor extends AbstractNodeVisitor implements NamedNodeVisitorInterface { use HasChildrenNodeVisitorTrait; protected function getDomNodeName(): string { return 'time'; } protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface { return new TimeNode($cursor->node); } public function getDefaultAllowedAttributes(): array { return ['datetime']; } } NodeVisitor/AbbrNodeVisitor.php000064400000001757150031564100012563 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\NodeVisitor; use HtmlSanitizer\Model\Cursor; use HtmlSanitizer\Extension\Extra\Node\AbbrNode; use HtmlSanitizer\Node\NodeInterface; use HtmlSanitizer\Visitor\AbstractNodeVisitor; use HtmlSanitizer\Visitor\HasChildrenNodeVisitorTrait; use HtmlSanitizer\Visitor\NamedNodeVisitorInterface; /** * @author Titouan Galopin * * @final */ class AbbrNodeVisitor extends AbstractNodeVisitor implements NamedNodeVisitorInterface { use HasChildrenNodeVisitorTrait; protected function getDomNodeName(): string { return 'abbr'; } protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface { return new AbbrNode($cursor->node); } } NodeVisitor/RubyNodeVisitor.php000064400000001757150031564100012636 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\NodeVisitor; use HtmlSanitizer\Model\Cursor; use HtmlSanitizer\Node\NodeInterface; use HtmlSanitizer\Extension\Extra\Node\RubyNode; use HtmlSanitizer\Visitor\AbstractNodeVisitor; use HtmlSanitizer\Visitor\HasChildrenNodeVisitorTrait; use HtmlSanitizer\Visitor\NamedNodeVisitorInterface; /** * @author Titouan Galopin * * @final */ class RubyNodeVisitor extends AbstractNodeVisitor implements NamedNodeVisitorInterface { use HasChildrenNodeVisitorTrait; protected function getDomNodeName(): string { return 'ruby'; } protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface { return new RubyNode($cursor->node); } } NodeVisitor/CaptionNodeVisitor.php000064400000001773150031564100013310 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\NodeVisitor; use HtmlSanitizer\Model\Cursor; use HtmlSanitizer\Extension\Extra\Node\CaptionNode; use HtmlSanitizer\Node\NodeInterface; use HtmlSanitizer\Visitor\AbstractNodeVisitor; use HtmlSanitizer\Visitor\HasChildrenNodeVisitorTrait; use HtmlSanitizer\Visitor\NamedNodeVisitorInterface; /** * @author Titouan Galopin * * @final */ class CaptionNodeVisitor extends AbstractNodeVisitor implements NamedNodeVisitorInterface { use HasChildrenNodeVisitorTrait; protected function getDomNodeName(): string { return 'caption'; } protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface { return new CaptionNode($cursor->node); } } NodeVisitor/HrNodeVisitor.php000064400000001745150031564100012263 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\NodeVisitor; use HtmlSanitizer\Model\Cursor; use HtmlSanitizer\Extension\Extra\Node\HrNode; use HtmlSanitizer\Node\NodeInterface; use HtmlSanitizer\Visitor\AbstractNodeVisitor; use HtmlSanitizer\Visitor\IsChildlessTagVisitorTrait; use HtmlSanitizer\Visitor\NamedNodeVisitorInterface; /** * @author Titouan Galopin * * @final */ class HrNodeVisitor extends AbstractNodeVisitor implements NamedNodeVisitorInterface { use IsChildlessTagVisitorTrait; protected function getDomNodeName(): string { return 'hr'; } protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface { return new HrNode($cursor->node); } } NodeVisitor/RtNodeVisitor.php000064400000001747150031564100012301 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\NodeVisitor; use HtmlSanitizer\Model\Cursor; use HtmlSanitizer\Node\NodeInterface; use HtmlSanitizer\Extension\Extra\Node\RtNode; use HtmlSanitizer\Visitor\AbstractNodeVisitor; use HtmlSanitizer\Visitor\HasChildrenNodeVisitorTrait; use HtmlSanitizer\Visitor\NamedNodeVisitorInterface; /** * @author Titouan Galopin * * @final */ class RtNodeVisitor extends AbstractNodeVisitor implements NamedNodeVisitorInterface { use HasChildrenNodeVisitorTrait; protected function getDomNodeName(): string { return 'rt'; } protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface { return new RtNode($cursor->node); } } NodeVisitor/MarkNodeVisitor.php000064400000001757150031564100012607 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\NodeVisitor; use HtmlSanitizer\Extension\Extra\Node\MarkNode; use HtmlSanitizer\Model\Cursor; use HtmlSanitizer\Node\NodeInterface; use HtmlSanitizer\Visitor\AbstractNodeVisitor; use HtmlSanitizer\Visitor\HasChildrenNodeVisitorTrait; use HtmlSanitizer\Visitor\NamedNodeVisitorInterface; /** * @author Titouan Galopin * * @final */ class MarkNodeVisitor extends AbstractNodeVisitor implements NamedNodeVisitorInterface { use HasChildrenNodeVisitorTrait; protected function getDomNodeName(): string { return 'mark'; } protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface { return new MarkNode($cursor->node); } } NodeVisitor/RpNodeVisitor.php000064400000001747150031564100012275 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\NodeVisitor; use HtmlSanitizer\Model\Cursor; use HtmlSanitizer\Node\NodeInterface; use HtmlSanitizer\Extension\Extra\Node\RpNode; use HtmlSanitizer\Visitor\AbstractNodeVisitor; use HtmlSanitizer\Visitor\HasChildrenNodeVisitorTrait; use HtmlSanitizer\Visitor\NamedNodeVisitorInterface; /** * @author Titouan Galopin * * @final */ class RpNodeVisitor extends AbstractNodeVisitor implements NamedNodeVisitorInterface { use HasChildrenNodeVisitorTrait; protected function getDomNodeName(): string { return 'rp'; } protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface { return new RpNode($cursor->node); } } Node/HrNode.php000064400000001124150031564100007312 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\Node; use HtmlSanitizer\Node\AbstractTagNode; use HtmlSanitizer\Node\IsChildlessTrait; /** * @author Titouan Galopin * * @final */ class HrNode extends AbstractTagNode { use IsChildlessTrait; public function getTagName(): string { return 'hr'; } } Node/AbbrNode.php000064400000001130150031564100007604 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\Node; use HtmlSanitizer\Node\AbstractTagNode; use HtmlSanitizer\Node\HasChildrenTrait; /** * @author Titouan Galopin * * @final */ class AbbrNode extends AbstractTagNode { use HasChildrenTrait; public function getTagName(): string { return 'abbr'; } } Node/RtNode.php000064400000001124150031564100007326 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\Node; use HtmlSanitizer\Node\AbstractTagNode; use HtmlSanitizer\Node\HasChildrenTrait; /** * @author Titouan Galopin * * @final */ class RtNode extends AbstractTagNode { use HasChildrenTrait; public function getTagName(): string { return 'rt'; } } Node/MarkNode.php000064400000001130150031564100007630 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\Node; use HtmlSanitizer\Node\AbstractTagNode; use HtmlSanitizer\Node\HasChildrenTrait; /** * @author Titouan Galopin * * @final */ class MarkNode extends AbstractTagNode { use HasChildrenTrait; public function getTagName(): string { return 'mark'; } } Node/CaptionNode.php000064400000001136150031564100010341 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\Node; use HtmlSanitizer\Node\AbstractTagNode; use HtmlSanitizer\Node\HasChildrenTrait; /** * @author Titouan Galopin * * @final */ class CaptionNode extends AbstractTagNode { use HasChildrenTrait; public function getTagName(): string { return 'caption'; } } Node/TimeNode.php000064400000001130150031564100007634 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\Node; use HtmlSanitizer\Node\AbstractTagNode; use HtmlSanitizer\Node\HasChildrenTrait; /** * @author Titouan Galopin * * @final */ class TimeNode extends AbstractTagNode { use HasChildrenTrait; public function getTagName(): string { return 'time'; } } Node/RubyNode.php000064400000001130150031564100007657 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\Node; use HtmlSanitizer\Node\AbstractTagNode; use HtmlSanitizer\Node\HasChildrenTrait; /** * @author Titouan Galopin * * @final */ class RubyNode extends AbstractTagNode { use HasChildrenTrait; public function getTagName(): string { return 'ruby'; } } Node/RpNode.php000064400000001124150031564100007322 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace HtmlSanitizer\Extension\Extra\Node; use HtmlSanitizer\Node\AbstractTagNode; use HtmlSanitizer\Node\HasChildrenTrait; /** * @author Titouan Galopin * * @final */ class RpNode extends AbstractTagNode { use HasChildrenTrait; public function getTagName(): string { return 'rp'; } }