Review main Merged

97620[TASK] Use native HTML5 parser in HtmlWorker

Benni Mack CR +2 V +2 Hard +472 −95 updated 11/14/26, 11:25

Commit message

HtmlWorker, the class behind the <f:transform.html> ViewHelper,
parsed markup with the third-party library masterminds/html5 and
traversed the result with the legacy DOM API.

PHP ships a spec-compliant HTML5 parser with \Dom\HTMLDocument
since PHP 8.4. HtmlWorker now parses the markup as a fragment in
the context of a <div> element and serializes it via innerHTML.
XPath queries are replaced by getElementsByTagName(), so that
selector input never ends up in a query expression.

In a local measurement with a 510 KB document, parsing and
serializing took about 8 ms instead of about 130 ms.

The output follows the WHATWG algorithms now, which changes the
result for invalid markup, see the changelog entry for details.
A unit test pins the behaviour of the class.

With HtmlWorker being the only consumer, the service
Masterminds\HTML5, its factory and the direct requirement of
masterminds/html5 are removed. The library is still installed as
dependency of typo3/html-sanitizer.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 10

Review log 68

  1. Benni Mack uploaded patch set 1 11/13/26, 15:46

  2. Benni Mack rebased onto patch set 2 11/13/26, 15:50

  3. core-ci voted on patch set 1 V +1 11/13/26, 18:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114357

  4. core-ci voted on patch set 2 V +1 11/13/26, 18:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114358

  5. Georg Ringer voted on patch set 2 CR +1 V +1 11/13/26, 19:30

  6. Simon Schaufelberger voted on patch set 2 CR +1 V +1 11/13/26, 22:31

  7. Benni Mack voted on patch set 2 CR +2 V +2 11/14/26, 11:25

  8. Benni Mack merged patch set 3 11/14/26, 11:25