sanitizeFor example

->allowRelativeLinks()
                ->allowRelativeMedias()
                ->forceHttpsUrls()
        );
    }

    /** * @dataProvider provideSanitizeHead */
    public function testSanitizeHead(string $input, string $expected)
    {
        $this->assertSame($expected$this->createSanitizer()->sanitizeFor('head', $input));
    }

    public static function provideSanitizeHead()
    {
        $cases = [
            // Scripts             [
                '<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">',
                '<link rel="stylesheet" />',
            ],

            
class HtmlSanitizerCustomTest extends TestCase
{
    public function testSanitizeForHead()
    {
        $config = (new HtmlSanitizerConfig())
            ->allowElement('div')
        ;

        $this->assertSame(
            ' world',
            (new HtmlSanitizer($config))->sanitizeFor('head', '<div style="width: 100px">Hello</div> world')
        );
    }

    public function testSanitizeForTextarea()
    {
        $config = (new HtmlSanitizerConfig())
            ->allowElement('div')
        ;

        $this->assertSame(
            '&lt;div style&#61;&#34;width: 100px&#34;&gt;Hello&lt;/div&gt; world',
            (
Home | Imprint | This part of the site doesn't use cookies.