.. include:: ../../Includes.txt

.. _breaking-99351-1670922139:

=========================================================
Breaking: #99351 - Upgrade to typo3/html-sanitizer v1.5.0
=========================================================

See :issue:`99351`

Description
===========

The package :php:`typo3/html-sanitizer` has been updated to version 1.5.0, introducing a syntactical change in the
underlying PHP API.


Impact
======

If a custom sanitizer is built and configured, several calls to the HTML Sanitizer API need adoption due to the change
of array arguments to variadic arguments.

Otherwise, the following or a similar exception is thrown:

.. code-block::

    TypeError: Argument 1 passed to TYPO3\HtmlSanitizer\Behavior\Tag::addAttrs() must be an instance of
    TYPO3\HtmlSanitizer\Behavior\Attr, array given, called in typo3/sysext/core/Classes/Html/DefaultSanitizerBuilder.php
    on line 75


Affected installations
======================

All installations using custom implementations of :php:`TYPO3\HtmlSanitizer\Builder\CommonBuilder` are affected.


Migration
=========

Migrate the following method calls to variadic usage:

* :php:`\TYPO3\HtmlSanitizer\Behavior\Attr->addValues()`
* :php:`\TYPO3\HtmlSanitizer\Behavior\Attr->withValues()`
* :php:`\TYPO3\HtmlSanitizer\Behavior\Tag->getAttrs()`

Example:

.. code-block:: php

    // Old usage
    (new Behavior\Tag('my-element', Behavior\Tag::ALLOW_CHILDREN))
        ->addAttrs(array_merge(
            [(new Behavior\Attr('href'))->addValues(
                new Behavior\RegExpAttrValue('#^(?:https?://|mailto:)#')
            )],
            $this->globalAttrs
        ))
    );


    // Migration
    (new Behavior\Tag('my-element', Behavior\Tag::ALLOW_CHILDREN))
        ->addAttrs(
            (new Behavior\Attr('href'))->addValues(
                new Behavior\RegExpAttrValue('#^(?:https?://|mailto:)#')
            ),
            $this->globalAttrs
        )
    );

.. index:: PHP-API, NotScanned, ext:core
