Issue Bug Closed

#109782parseFunc return wrong html in case of remap

Sebastien Convers 05/06/26, 13:09 updated 08/11/26, 08:47

Description

I was trying to play with ckeditor and lib.parseFunc_RTE, and i notice a bug when using remap (https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Functions/HtmlparserTags.html#remap)

I tried to remap blockquote as div

lib.parseFunc_RTE {
  externalBlocks {
    blockquote {
      callRecursive.tagStdWrap.HTMLparser = 1
      callRecursive.tagStdWrap.HTMLparser {
        tags.blockquote.remap = div
      }
    }
  }
}

In my RTE, i had html similar to this

<p>Paragraph 1</p>
<blockquote>
  <p>Paragraph 2</p>
  <p>Paragraph 3</p>
</blockquote>
<p>Paragraph 4</p>

Then in front, i ended up with this wrong html

<p>Paragraph 1</p>
<div>
  <p>Paragraph 2</p>
  <p>Paragraph 3</p>
  <p>Paragraph 4</p>
</div>

After some digging i found the problem comes from https://github.com/TYPO3/typo3/blob/e7c2bebe29af01996a47b0136d2b39730c68975f/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php#L2903

if (is_array($cfg[‘callRecursive.’][‘tagStdWrap.’] ?? false)) {
$tag = $this->stdWrap($tag, $cfg[‘callRecursive.’][‘tagStdWrap.’]);
}
$parts[$k] = $tag . $parts[$k] . ‘</’ . $tagName . ‘>’;

Here, $tag is remapped from blockquote to div , but $tagName , use to make the closing tag, is still blockquote

Generated html is then

<p>Paragraph 1</p>
<div>
  <p>Paragraph 2</p>
  <p>Paragraph 3</p>
</blockquote>
<p>Paragraph 4</p>

And so ended up getting “wrongly fixed” later in the process with the removal of </blockquote> , and addition of </div> in the very end of the bloc

If would fix it like this

if (is_array($cfg[‘callRecursive.’][‘tagStdWrap.’] ?? false)) {
$tag = $this->stdWrap($tag, $cfg[‘callRecursive.’][‘tagStdWrap.’]);
// Refresh tag name in case of remap
$tagName = strtolower($htmlParser->getFirstTagName($tag));
}
$parts[$k] = $tag . $parts[$k] . ‘</’ . $tagName . ‘>’;

Reviews 2

Files 6

History 38

  1. Sebastien Convers commented and changed attached rte_1.png attached rte_source.png attached result_1.png attached wrong_html.png attached result_fix.png attached html_fix.png <span data-processor="relativetime" data-value="2026-05-27T07:07:53+00:00" > 05/27/26, 07:07 </span>

    Test case : remap “
    “ to “
    lib.parseFunc_RTE {
      externalBlocks {
        blockquote {
          callRecursive.tagStdWrap.HTMLparser = 1
          callRecursive.tagStdWrap.HTMLparser {
            tags.blockquote.remap = div
            tags.blockquote.fixAttrib.class.default = fr-highlight
          }
        }
      }
    }
  2. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-06-19T12:20:09+00:00" > 06/19/26, 12:20 </span>

    Applied in changeset commit:ad3cda0b8698c0a79f7b257d02e23fb0e060b5b0.