$this->
assertSame( '<img src="https://trusted.com" />',
$this->
sanitize($config, '<img src="https://trusted.com" />'
) );
} public function testCustomAttributeSanitizer() { $config =
(new HtmlSanitizerConfig()) ->
allowElement('div',
['data-attr'
]) ->
withAttributeSanitizer(new class() implements AttributeSanitizerInterface
{ public function getSupportedElements(): ?array
{ return ['div'
];
} public function getSupportedAttributes(): ?array
{ return ['data-attr'
];
} public function sanitizeAttribute(string
$element, string
$attribute, string
$value, HtmlSanitizerConfig
$config): ?string
{