'TYPO3 fluid: f:format.html in backend removes links

I am using flux 9.5.0 in TYPO3 9.5.31 to create a simle "text" content element.

It has a preview section that is displayed in the TYPO3 backend with <f:format.html>:

  <f:section name="Preview">
    <f:format.html>{settings.text}</f:format.html>
  </f:section>

Unfortunately, links get removed and are not even their text displayed.

Example:

  • HTML in RTE: <p>before <a href="https://cweiske.de/" target="_blank">link</a> after</p>
  • Rendered output in preview: before after

How can I get the links in the preview section rendered?



Solution 1:[1]

This is a problem with TYPO3's fluid.

TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper::simulateFrontendEnvironment() creates a dummy TSFE instance.

TYPO3's ContentObjectRenderer expects $TSFE->cObjectDepthCounter to be > 0 when rendering nested tags in cObjGetSingle, and this fails because the dummy TSFE instance does not have this variable set.


This problem is known since 2015: Bug #66855: Format/HtmlViewHelper don't render Links in TYPO3_MODE = BE

According to https://forge.typo3.org/issues/67556 and https://forge.typo3.org/issues/96535 this is "fixed" in TYPO3 v11.5 if you switch to <f:transform.html>.

Solution 2:[2]

There was a change in version 9.5.29 due to security reasons.

See: https://typo3.org/security/advisory/typo3-core-sa-2021-013

How to fix: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.5.x/Important-94484-IntroduceHTMLSanitizer.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Thomas Löffler